| Python 2.2 für Einsteiger | ||
|---|---|---|
| <<< Previous | Einführung anhand von Beispielen | |
#!/usr/bin/python
class Baer:
pass
class Schachtel(Baer):
pass
class Kiste(Schachtel):
pass
for c in [Baer, Schachtel, Kiste]:
try:
raise c()
except Kiste:
print "Kiste"
except Schachtel:
print "Schachtel"
except Baer:
print "Baer"
"""
[stepken@home python]$ ./classinherit.py
Baer
Schachtel
Kiste
"""
| <<< Previous | Home | |
| MAP, REDUCE | Up |