Do While Loop Equivalent
Hi, I have been searching for a while but I am coming up empty. I am writing a module that needs to create a block of records in the db so they can be updated at a later time. In the good old days, I would use a do while loop (do something while x < 10). How can this be done? And as always any pointers will be appreciated, thanks. Larry McDonnell Proton Energy Systems 10 Technology Drive Wallingford, CT 06492 (203) 678-2181 Email:lmcdonnell@protonenergy.com www.protonenergy.com
<dtml-in "_.range(9)"> ... add block of records </dtml-in> Was that what you wanted? David ----- Original Message ----- From: "McDonnell, Larry" <lmcdonnell@protonenergy.com> To: "'Zope@Zope. Org' (E-mail)" <zope@zope.org> Sent: Wednesday, May 21, 2003 12:55 PM Subject: [Zope] Do While Loop Equivalent
Hi,
I have been searching for a while but I am coming up empty. I am writing a module that needs to create a block of records in the db so they can be updated at a later time. In the good old days, I would use a do while loop (do something while x < 10). How can this be done? And as always any pointers will be appreciated, thanks.
Larry McDonnell
Proton Energy Systems 10 Technology Drive Wallingford, CT 06492 (203) 678-2181 Email:lmcdonnell@protonenergy.com www.protonenergy.com
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
In Python? ZPT? DTML??? --On Mittwoch, 21. Mai 2003 15:55 Uhr -0400 "McDonnell, Larry" <lmcdonnell@protonenergy.com> wrote:
Hi,
I have been searching for a while but I am coming up empty. I am writing a module that needs to create a block of records in the db so they can be updated at a later time. In the good old days, I would use a do while loop (do something while x < 10). How can this be done? And as always any pointers will be appreciated, thanks.
Larry McDonnell
Proton Energy Systems 10 Technology Drive Wallingford, CT 06492 (203) 678-2181 Email:lmcdonnell@protonenergy.com www.protonenergy.com
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
What's the context-- Python, DTML, ZPT, ??? On Wed, 21 May 2003, McDonnell, Larry wrote:
I have been searching for a while but I am coming up empty. I am writing a module that needs to create a block of records in the db so they can be updated at a later time. In the good old days, I would use a do while loop (do something while x < 10). How can this be done? And as always any pointers will be appreciated, thanks.
By "module" I assume you mean a Python product? Python has a while statement: ---------- while test: action ---------- Honestly, though, there's almost no good reason to use it. :-) While does little that couldn't be handled better by a for statement or a list comprehension. Mostly it's there for buzzword compliance. For example, if you've got a dictionary of records, it's quite easy to step through each one and perform some action: --------- for record in records.keys(): do_something(records[record]) --------- Or use a list comprehension: --------- [do_something(records[record]) for record in records.keys()] --------- When you've got options like that why would you prefer: --------- rst_size = len(records.keys()) i = 0 while i < rst_size: do something(records[i]) i += 1 --------- If you're still having trouble seeing how to do what you need to, it would be helpful to know a bit more about what you're attempting, what you've tried, and what isn't working about your solution. HTH, Dylan On Wed, 2003-05-21 at 12:55, McDonnell, Larry wrote:
Hi,
I have been searching for a while but I am coming up empty. I am writing a module that needs to create a block of records in the db so they can be updated at a later time. In the good old days, I would use a do while loop (do something while x < 10). How can this be done? And as always any pointers will be appreciated, thanks.
Larry McDonnell
Proton Energy Systems 10 Technology Drive Wallingford, CT 06492 (203) 678-2181 Email:lmcdonnell@protonenergy.com www.protonenergy.com
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (5)
-
Andreas Jung -
David Hassalevris -
Dennis Allison -
Dylan Reinhardt -
McDonnell, Larry