SHARE
TWEET

Untitled

a guest Apr 21st, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Person:
  2.     def __init__(self, age):
  3.         self.age = age
  4.  
  5. per1 = Person(20)
  6. per2 = Person(30)
  7.  
  8. l = [per1, per2]
  9. print(sum([getattr(x, 'age') for x in l]))
  10.    
  11. print(sum([getattr(x, 'age') for x in l]))
RAW Paste Data
Top