SHARE
TWEET

Untitled

a guest Jun 24th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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"]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top