Alle Dateien aus dem Pythonkurs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
385 B

# Datei: classdecor.py
def addrepr(cls):
# Universelle __repr__ Methode
def __repr__(self):
return f"{cls.__name__}({self.__dict__})"
cls.__repr__ = __repr__
return cls
@addrepr
class Fahrzeug():
def __init__(self,farbe,typ):
self.typ = typ
self.farbe = farbe
f1 = Fahrzeug('grau','VW')
f2 = Fahrzeug('rot','Ferrari')
print(f'{f1}')
print(f'{f2}')