Another try at Python's selfishness
n.estner at gmx.de
n.estner at gmx.de
Thu Feb 2 19:56:06 EST 2006
Definitely looks interesting. I'd like it more if it was more explicit,
but still, it does look nice.
I guess you could make it recursion-safe if you saved/restored the
global "__" variable before/after calling the actual function, and
probably there's a way to make it thread-safe, too. But how would you
make it generator-safe? Also, wouldn't lambda's you pass around from
object to object be bound to use the wrong instance? How would you fix
this code:
class TestA:
@memberFunction
def do(f):
print f()
class TestB:
@memberFunction
def do(x):
x.do(lambda : __)
TestB().do(TestA()) # should print out TestB, does print out TestA
There really should be something like a wiki for
"selfishness"-proposals with pros and cons, so I could have looked at
some before thinking about my own one...
More information about the Python-list
mailing list