Quick actions

cmd+k|ctrl+k

Navigation

Languages

OOP

Snippet info

Language

Python

Visibility

public

Author

projectsfiae

Created

2025-08-27T11:00:00.683982Z

Updated

2025-08-27T13:50:44.206666Z

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, '[email protected]')
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'])












INFO