How to do this in Python...
exarkun at intarweb.us
Fri Jan 24 23:04:24 CET 2003
On Fri, Jan 24, 2003 at 03:08:26PM -0500, Michael Tiller wrote:
> I want to be clear about something. I have no particular fondness for
> if (a=b) then ...
> "feature" in C. I agree that *THAT SYNTAX* is confusing.
When all you're saving is a single line of code, I can't see why it's even
worth discussing at such length. This is so commonly desired, though, that
a while ago I wrote this... http://intarweb.us:8080/evil/assignment.py
(Un)fortunately, with recent interpreter changes, it no longer works for
code anywhere but at the top-level of a module.
I imagine a similar function could be written that worked with more recent
versions of Python, if one so desired. I think that if you're going this
route at all, an explicit function call is better than the bizarre list-comp
based solution discussed elsewhere in the thread.
"There is no reason for any individual to have a computer in their
-- Ken Olson, President of DEC, World Future Society
up 40 days, 1:49, 7 users, load average: 0.60, 0.63, 0.62
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 196 bytes
Desc: not available
More information about the Python-list