Created
March 2, 2014 10:59
-
-
Save hahastudio/9304929 to your computer and use it in GitHub Desktop.
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
>>> class AAA(object): | |
... def go(self): | |
... self.one = 'hello' | |
... | |
>>> class BBB(object): | |
... def go(self): | |
... one = 'hello' | |
... | |
>>> a1 = AAA() | |
>>> a1.go() | |
>>> a1.one | |
'hello' | |
>>> a2 = AAA() | |
>>> a2.one | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
AttributeError: 'AAA' object has no attribute 'one' | |
>>> a2.go() | |
>>> a2.one | |
'hello' | |
>>> b1 = BBB() | |
>>> b1.go() | |
>>> b1.one | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
AttributeError: 'BBB' object has no attribute 'one' | |
>>> BBB.one | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
AttributeError: type object 'BBB' has no attribute 'one' | |
>>> class BBB(object): | |
... def go(self): | |
... one = 'hello' | |
... print one | |
... self.another = one | |
... | |
>>> b2 = BBB() | |
>>> b2.go() | |
hello | |
>>> b2.another | |
'hello' | |
>>> b2.one | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
AttributeError: 'BBB' object has no attribute 'one' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment