Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import inspect
- class Napraw(object):
- def __init__(self, m, b):
- super().__init__()
- self.m = m
- self.b = b
- class Tagi(object):
- m = None
- b = None
- def __init__(self):
- super().__init__()
- # tylko argumenty inne niż None będą przypisane do atrybutu obiektu
- def setup(self, m=None, b=None):
- args, _, _, _ = inspect.getargvalues(inspect.currentframe())
- for arg in args:
- if locals()[arg] is not None:
- setattr(self, arg, locals()[arg])
- @classmethod
- def with_args(cls, m, b):
- o = cls()
- o.setup(m, b)
- return o
Advertisement
Add Comment
Please, Sign In to add comment