sunsexsurf

class_Coin

May 10th, 2020
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. class Coin:
  2.  
  3.     def __init__(self, **kwargs):
  4.         for k, v in kwargs.items():
  5.             setattr(self, k, v)
  6.  
  7.     def __call__(self, *args, **kwargs):
  8.         for value in args:
  9.             if type(value) in (int, float):
  10.                 self.__setattr__('price', float(value))
  11.  
  12.     def todict(self):
  13.         return {attr: getattr(self, attr) for attr in dir(self)
  14.                 if not callable(getattr(self, attr)) and not attr.startswith("__")}
Advertisement
Add Comment
Please, Sign In to add comment