-
-
Save masak/93815861a74c571c784f to your computer and use it in GitHub Desktop.
Assigning to a random attribute in a method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python | |
Python 2.7.6 (default, Mar 22 2014, 22:59:56) | |
[GCC 4.8.2] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> class C(object): | |
... def foo(self): | |
... self.bar = 42 | |
... | |
>>> c = C() | |
>>> c.foo() | |
>>> c.bar | |
42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment