Skip to content

Instantly share code, notes, and snippets.

@tanarurkerem
Created February 18, 2023 07:29
Show Gist options
  • Select an option

  • Save tanarurkerem/30cc5b2566f6f63cdba4e0bf99e38985 to your computer and use it in GitHub Desktop.

Select an option

Save tanarurkerem/30cc5b2566f6f63cdba4e0bf99e38985 to your computer and use it in GitHub Desktop.
class Animal:
def __init__(self):
self.firstname = 'maci'
self.lastname = 'laci'
self.fullname = self.firstname + self.lastname
def __setattr__(self, __name: str, __value: any) -> None:
super().__setattr__(__name, __value)
try:
if __name == 'firstname' or __name == 'lastname':
self.fullname = self.firstname + self.lastname
except:
pass
class Dog(Animal):
def __init__(self):
super().__init__()
self.firstname = 'Bello'
self.lastname = 'Kutyus'
oneDog = Dog()
print (oneDog.fullname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment