If you want X, you know where to find it (was Re: do...until wisdom needed...)
Douglas Alan
nessus at mit.edu
Sun Apr 22 15:52:23 EDT 2001
jepler at inetnebr.com (Jeff Epler) writes:
> This particular example can be done with very nearly the same syntax in
> standard Python---a dot instead of whitespace between let/set and the
> variable in question.
> >>> import letset, __main__; letset.setup(__main__)
> >>> let.x = 3
> >>> x
> 3
> >>> let.x = 4
> Traceback (most recent call last):
Thanks for the ideas. I think my coworkers might kill me if I
programmed this way, though.
How do I use this for local variables? Like so?
import letset
class Locals: pass
def add10(x):
l = Locals()
letset.setup(l)
l.let.y = 10
return x + l.y
Seems kind of cumbersome and slow and doesn't handle variable "x".
|>oug
More information about the Python-list
mailing list