ch06
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# oop/simplest.class.py
|
||||
class Simplest(): # when empty, the braces are optional
|
||||
pass
|
||||
|
||||
print(type(Simplest)) # what type is this object?
|
||||
|
||||
simp = Simplest() # we create an instance of Simplest: simp
|
||||
print(type(simp)) # what type is simp?
|
||||
# is simp an instance of Simplest?
|
||||
print(type(simp) is Simplest) # There's a better way to do this
|
||||
|
||||
|
||||
"""
|
||||
$ python simplest.class.py
|
||||
<class 'type'>
|
||||
<class '__main__.Simplest'>
|
||||
True
|
||||
"""
|
||||
Reference in New Issue
Block a user