object
does not have __dict__
attribute, thus its instantiations can't be updatedIn [1]: dir(object) Out[1]: ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
(May-01-2017, 04:14 PM)Larz60+ Wrote: Seems to me you should have received this error immediately:
here, was x already declared
Error:>>> x.name = 'Fred' Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'x' is not defined >>>
What was the
type
of your x
In [4]: class X(object): ...: pass ...: In [5]: x = X() In [6]: x.name = 'Fred' In [7]: '__dict__' in dir(X) Out[7]: True
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.