Python: AttributeError while creating a new property of an object via assignment -
i following assignment (file class):
file_object = file() file_object.file_type = file_type and get:
attributeerror: 'file' object has no attribute 'file_type' how can be?
i thought, add attributes dynamically (and worked before).
i've upgraded python 2.7.13, , have problem.
file (in case) has __dict__ , not have __slot__:
>>> print dir(file) ['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'factory', 'method_name']
i think code reading file() object, not class - https://docs.python.org/2.4/lib/bltin-file-objects.html.
Comments
Post a Comment