Weird generator id() behaviour (was Re: Python code written in 1998, how to improve/change it?)
Wolfgang Keller
wolfgang.keller.nospam at gmx.de
Tue Jan 24 16:53:18 EST 2006
On Tue, 24 Jan 2006 21:19:26 +0100, Carl Cerecke wrote
(in article <43d68bd0 at usenet01.boi.hp.com>):
> def g_on():
>
> print "on"
> action = next_action()
> if action == 'lift':
> yield g_on()
> elif action == 'push':
> yield g_off()
> else:
> yield None
>
> def g_off():
>
> print "off"
> action = next_action()
> if action == 'lift':
> yield g_on()
> elif action == 'push':
> yield g_off()
> else:
> yield None
Amazing.
Executable pseudo-code, really. :-)
And that's even (run-time) efficient?
Tanks a lot,
Sincerely,
Wolfgang Keller
More information about the Python-list
mailing list