OOP

Run Settings
LanguagePython
Language Version
Run Command
class User(object): def __init__(self, email): self.email = email def sign_in(self, email): print('logged in') class Wizard(User): def __init__(self, name, power, email): super().__init__(email) self.name = name self.power = power def attack(self): User.attack(self) print(f'attacking with power of {self.power} ') wizard1 = Wizard('Merlin', 60, 'm@gmail.com') print(wizard1.email) # introspection print(dir(wizard1)) # dunder methods class Toy(): def __init__(self,color,age): self.color = color self.age = age self.my_dict = { 'name': 'yoyo', 'has_pets': False } def __str__(self): return f'{self.color}' def __len__(self): return 5 def __call__(self): return('yess???') def __getitem__(self, i): return self.my_dict[i] action_figure = Toy('red',0) print(action_figure.__str__()) print(str(action_figure)) print(len(action_figure)) print(action_figure()) print(action_figure['name'])
Editor Settings
Theme
Key bindings
Full width
Lines