No "side effect" assignment!

Tobiah toby at rcsreg.com
Sun Sep 14 17:50:15 EDT 2003


Ok,

I miss the idiom that my other languages use,
something like:


while( foo = getmore()){
	process(foo);
}


I can't seem to do this in python without gagging:

foo = getmore()
while foo:
	process(foo)
	foo = getmore()


Is that what ppl do?  The manual sez that this is
so that newbs won't do:

if foo = bar:
	process()

thinking that they are checking for equality.
I feel that in a few ways python suffers by catering
to the uninitiated.  Usually however, there are
great workarounds (or even plain better ways to do the job),
which I am hopeful will be yielded by the list, as has
been it's record thus far to do.

Thanks,

Tobiah





More information about the Python-list mailing list