I'm coming from Tcl-world ...
Andreas Leitgeb
Andreas.Leitgeb at siemens.at
Mon Aug 5 08:43:24 EDT 2002
Hans Nowak <wurmy at earthlink.net> wrote:
> Andreas Leitgeb wrote:
> That is understandable, coming from another language and being used to
> different idioms.
Whenever I start to peek into a new language, I try to recognize
some abstract elements in it.
one of these "abstract elements" is described as such:
'A loop, whose body can directly and freely modify the
loop-var, thereby controlling the loop'
(one might for example want to step back one iteration eventually,
which seems unachievable with iterator-based loops)
('freely' means more than continue&break)
In C/C++/Java/perl/Tcl there is the for-loop that fulfills it.
Python lacks it.
Of course, one might question the usefulness of this feature,
but that's not in the scope of my original question.
Whether I really need it and whether and with what magic tricks I can
do without it, practise will show.
> Why not: [ replace continue with an if and make everything after
> the continue part of the if-block]
I wrote: the location of continue may be nested arbitrarily deep down
inside other if's.
> I don't know which book you used to learn Python, but it seems it taught you
> the right things and common "Pythonic" idioms.
It is the german translation of:
"Python Pocket Reference (2nd edition)" ("Python kurz&gut")
> you may find yourself using the other constructs anyway, because they "feel
> better". Just give them a try.
Yes, of course.
My intended question was not, how to program C/Tcl in python, but what
are Python's idioms for the mentioned "tasks".
The reason, this thread grew so fast, was that obviously I didn't
specify these "tasks" well enough.
--
Newsflash: Sproingy made it to the ground !
read more ... <http://avl.enemy.org/sproingy/>
More information about the Python-list
mailing list