Guest User

Untitled

a guest
Mar 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. inside a class:
  2. def __repr__(self):
  3. ignore = ['logger']
  4. repr = ""
  5. for key, item in self.__dict__.items():
  6. if key in ignore: continue
  7. repr += f"{key}:{item}\n"
  8. return repr
  9.  
  10.  
  11. inside class:
  12. self.logger.info(self) # uses the __repr__
  13.  
  14. outside of class:
  15. logger.info(object) # uses the __repr__
Add Comment
Please, Sign In to add comment