Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. person = {
  2. 'name': Jane,
  3. 'yearofbirth': 1995,
  4. 'yearnow': 2019,
  5. 'age': person['yearnow'] + person['yearofbirth']
  6. }
  7.  
  8. class MyDict(dict):
  9. def __getitem__(self, item):
  10. return dict.__getitem__(self, item) % self
  11.  
  12. dictionary = MyDict({
  13.  
  14. 'user' : 'gnucom',
  15. 'home' : '/home/%(user)s',
  16. 'bin' : '%(home)s/bin'
  17. })
  18.  
  19.  
  20. print dictionary["home"]
  21. print dictionary["bin"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement