Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Python mehrfachvererbung
#python 3.6.9 class TwoDPoint: def __init__(self, x=0, y=0): self.x = x self.y = y class ThreeDPoint(TwoDPoint): def __init__(self, z): self.z = z super().__init__() # so zu lesen: super() sozusage gibt eine ref zur Klasse zurueck # und __init__ ist in diesem Sinne eine klassenmethode # => TwoDPoint.__init__() class Description: def __init__(self, text="irgend eine Beschreibung...."): self.text = text class Composit(ThreeDPoint, Description): def __init__(self, z=0): ThreeDPoint.__init__(self, z) Description.__init__(self) cd = Composit() print(cd.x, cd.y, cd.z, cd.text) # default cp = Composit(555) print(cp.x, cp.y, cp.z, cp.text) # param
run
|
edit
|
history
|
help
0
linked_lists
Random number
DICTIONARY PROBLEM
http
правильные окончания
75
linked_lists
My name
15
PyDescript