Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78387758
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
Tue, Aug 20, 12:55
Size
731 B
Mime Type
text/x-python
Expires
Thu, Aug 22, 12:55 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
20025426
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