Skip to content

Instantly share code, notes, and snippets.

@makmanalp
Created June 6, 2016 04:25
Show Gist options
  • Save makmanalp/47f8f161f704285f88746f2ae3960ec7 to your computer and use it in GitHub Desktop.
Save makmanalp/47f8f161f704285f88746f2ae3960ec7 to your computer and use it in GitHub Desktop.
Code in the body of a class - 8
In [83]: class Foo(object):
for i in range(3):
setattr(Foo, "x"+str(i), i)
....:
In [84]: Foo.x0
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-84-e9bd27bad8bd> in <module>()
----> 1 Foo.x0
AttributeError: type object 'Foo' has no attribute 'x0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment