mutable default parameter problem [Prothon]
Antoon Pardon
apardon at forel.vub.ac.be
Mon Jun 28 07:21:09 EDT 2004
Op 2004-06-25, Mark Hahn schreef <mark at prothon.org>:
>
> There are many clean readable programming conventions that rely on return
> values. This is certainly an acceptable construct, right?
>
> while len(list.append!(x)) < 10:
> blah blah blah
>
> Compare that to the less readable and less maintainable Python version:
>
> list.append(x)
> while len(list) < 10:
> blah blah
> list.append(x) # duplicate code
>
> I can come up with many more. I think when you have been without a language
> feature for a while you tend to block it out of your mind.
Well personnally I would solve this with a more general loop construct.
Something like: (Pseudo code)
loop:
list.append(x)
while len(list) < 10:
blah blah.
The more general construct would be something like:
loop:
code
while condition1:
code
else:
exit code if condition1 fails
while condition2:
code
else:
exit code if condion2 fail
Does prothon provide for such a general loop?
More information about the Python-list
mailing list