Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91135691
cats_and_dogs.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 8, 06:46
Size
731 B
Mime Type
text/x-python
Expires
Sun, Nov 10, 06:46 (2 d)
Engine
blob
Format
Raw Data
Handle
22203281
Attached To
R7571 SP4E-TB-TL-FR
cats_and_dogs.py
View Options
#!/usr/bin/env python3
class
Animal
(
object
):
def
__init__
(
self
,
name
=
'kitty'
):
self
.
name
=
name
def
__del__
(
self
):
pass
class
Dog
(
Animal
):
# the constructor needs to call the parent one
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
def
__del__
(
self
):
super
()
.
__del__
()
def
scream
(
self
):
print
(
'OUAFF'
)
class
Cat
(
Animal
):
# the constructor needs to call the parent one
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
def
__del__
(
self
):
super
()
.
__del__
()
def
scream
(
self
):
print
(
'MIAOU'
)
d
=
Dog
(
'puppy'
)
print
(
d
.
name
)
d
.
scream
()
c
=
Cat
()
print
(
c
.
name
)
c
.
scream
()
Event Timeline
Log In to Comment