Re: [Tutor] for vs while

2007-09-29 Thread Alan Gauld
"James" <[EMAIL PROTECTED]> wrote > I have a dumb question...hopefully someone can shed some light on > the > difference between for and while in the situation below. You got the basic answer but I'll just add a comment. while is your basic type loop, same as in C and most other languages. for

Re: [Tutor] for vs while

2007-09-28 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Try: for item in stuff: os.system(item[0]) print item[1] Alternativly: for cmd, msg in stuff: os.system(cmd) print msg Andreas James wrote: > All, > > I have a dumb question...hopefully someone can shed some light on the > diffe

Re: [Tutor] for vs while

2007-09-28 Thread James
I shiver at the thought of Perl. ;) Thanks to everyone for your quick and helpful responses! .james On Sep 28, 2007, at 11:25 AM, Kent Johnson wrote: > James wrote: >> Great! I was under the impression that the range was implied, but >> I guess not. ;) > > No. One of the core Python value

Re: [Tutor] for vs while

2007-09-28 Thread Kent Johnson
James wrote: > Great! I was under the impression that the range was implied, but I > guess not. ;) No. One of the core Python values is "Explicit is better than implicit." If you like implicit behaviour, try Perl ;-) Type 'import this' at the Python prompt for more... Kent _

Re: [Tutor] for vs while

2007-09-28 Thread Joshua Simpson
On 9/28/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > > It's worth your time learning about Python data structures and for > loops. They are very powerful and useful and unlike anything built-in to > C. With a background in C you should find the official tutorial pretty > easy to read: > http://d

Re: [Tutor] for vs while

2007-09-28 Thread Joshua Simpson
On 9/28/07, James <[EMAIL PROTECTED]> wrote: > > > # doesn't work > for i in len( stuff ): > os.system( stuff[ i ] ) > j = i + 1 > print stuff[ j ] > > > Traceback (most recent call last): >File "", line 1, in > TypeError: 'int' o

Re: [Tutor] for vs while

2007-09-28 Thread Kent Johnson
James wrote: > All, > > I have a dumb question...hopefully someone can shed some light on the > difference between for and while in the situation below. > > I'm trying to iterate through a list I've created. The list consists > of a command, followed by a 'logging' message (a message printed

Re: [Tutor] for vs while

2007-09-28 Thread James
On Sep 28, 2007, at 10:59 AM, bob gailer wrote: > James wrote: >> All, >> >> I have a dumb question...hopefully someone can shed some light on >> the difference between for and while in the situation below. >> >> I'm trying to iterate through a list I've created. The list >> consists of a c

Re: [Tutor] for vs while

2007-09-28 Thread taserian
On 9/28/07, James <[EMAIL PROTECTED]> wrote: > > All, > > I have a dumb question...hopefully someone can shed some light on the > difference between for and while in the situation below. > > I'm trying to iterate through a list I've created. The list consists > of a command, followed by a 'logging

Re: [Tutor] for vs while

2007-09-28 Thread bob gailer
James wrote: > All, > > I have a dumb question...hopefully someone can shed some light on the > difference between for and while in the situation below. > > I'm trying to iterate through a list I've created. The list consists > of a command, followed by a 'logging' message (a message printed t

[Tutor] for vs while

2007-09-28 Thread James
All, I have a dumb question...hopefully someone can shed some light on the difference between for and while in the situation below. I'm trying to iterate through a list I've created. The list consists of a command, followed by a 'logging' message (a message printed to a console or log file