On 06/20/2019 01:25 PM, nate lust wrote:
--> class Foo:
... def __init__(self, o):
... self.o = o
... def __setself__(self, v):
... self.v = v
...
--> f = Foo(5)
--> print(f)
<__main__.Foo object at 0x7f486bb8d300>
--> print(f.o)
5
>>> print(f.v)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Foo' object has no attribute 'v'
--> f = "hello world"
--> print(f.v)
hello world
--> print(f)
<__main__.Foo object at 0x7f486bb8d300>
Thank you for doing the work of a proof-of-concept (and to Andrew Barnert for
his excellent write-up). I think this shows exactly why it's a bad idea --
even though I knew what you were doing, having `f` not be a string after the
assignment was extremely surprising.
-1
--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/AFPG55GOZI2U6FK6N2VXYPAQDIJ36ATM/
Code of Conduct: http://python.org/psf/codeofconduct/