Skip to content

Instantly share code, notes, and snippets.

@aodag
Created January 8, 2012 19:41
Show Gist options
  • Save aodag/1579425 to your computer and use it in GitHub Desktop.
Save aodag/1579425 to your computer and use it in GitHub Desktop.
pythonの組み込み型に見られる特徴
>>> a.__dict__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute '__dict__'
>>> a = 10
>>> a.__dict__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute '__dict__'
>>> a = 1.0
>>> a.__dict__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'float' object has no attribute '__dict__'
>>> a = "a"
>>> a.__dict__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute '__dict__'
>>> a = True
>>> a.__dict__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'bool' object has no attribute '__dict__'
>>> class A(object):
... pass
...
>>> a = A()
>>> a.__dict__
{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment