forked from qiwsir/StarterLearningPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path21101.py
More file actions
31 lines (21 loc) · 429 Bytes
/
21101.py
File metadata and controls
31 lines (21 loc) · 429 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
# coding=utf-8
"the code is from: http://zetcode.com/lang/python/oop/"
__metaclass__ = type
class Animal:
def __init__(self, name=""):
self.name = name
def talk(self):
pass
class Cat(Animal):
def talk(self):
print "Meow!"
class Dog(Animal):
def talk(self):
print "Woof!"
a = Animal()
a.talk()
c = Cat("Missy")
c.talk()
d = Dog("Rocky")
d.talk()