I was wondering if it is possible to have a function return a reference to itself specifically without using an object to facility the reflection. (don't ask why.) This kind of works but no dice because I'm not asking about a bound method
I'm asking about function
.
>>> class test:
... def ex(self):
... return(self.ex)
...
>>> t = test()
>>> a = t.ex()
>>> b = t.ex
>>> a==b
True
>>> a()
<bound method test.ex of <__main__.test object at 0x033189F0>>
>>> b()
<bound method test.ex of <__main__.test object at 0x033189F0>>
I also tried with a def
but obviously I had nothing to return...
>>> def test():
... return(self)
...
>>> test()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in test
NameError: name 'self' is not defined
Finally I typed the word lambda
into the terminal and then just said 'yeah, that's not happening... lulz'.
Aucun commentaire:
Enregistrer un commentaire