If you need the index, then use an indexed for using range() and len() as
generators:
>>> for i in range( 0, len( tmp )):
... { do something to tmp[i] }
>
> It would be nice if iterationCount were a pre-defined register like @i
> or something so the code could be more compact . However, it would be
> more cryptic to someone just getting into the language. Registers were
> the main thing that made me quit learning Perl quickly.
>
I would NOT want to PERL-ify Python ( at least in THAT sense )!
I agree that that sort of stuff is part of why Perl is hard to read and learn.
A long time ago, I asked Guido for some remarks on his sense of what role
Python was meant to fill. *IF* the role was to be largely an interactive
command language, THEN brevity has a much higher weight as a virtue.
Perl, IMHO, since it is less interactive than Python, fills that sort of
role more poorly, so I see even less excuse for that sort of abbreviation.
[ We want an interactive language to have aliases and other abbreviations,
but once we start using an editor to enter larger scripts, then readability
becomes more virtuous than conciseness. ( IMHO ) ]
>
> Another way to look at this is that since Python is an object-oriented
> language the for statement above is sending a message to `for' with 2
> arguments. Since objects have their own private data, it would seem
> that we could type serverloop_code.insert(for.current_pos(), line) at
> line X to access some data in the `for' object.
>
> What do you all think ?
>
Since Python is not a "pure" object-oriented language, there is no way to
send 'for' a message. But you COULD define an object that keeps count of
the number of times it has been assigned to. It would have two instance
variables: value and count; and a method that updates value and increments
count.
- - Steve
======== "If you have a hammer, find a nail" - George Bush,'91 =========
Steven D. Majewski University of Virginia Physiology Dept.
sdm7g@Virginia.EDU Box 449 Health Sciences Center
Voice: (804)-982-0831/32 1300 Jefferson Park Avenue
FAX: (804)-982-1616 Charlottesville, VA 22908
------- End of forwarded message -------