Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- person = {
- 'name': Jane,
- 'yearofbirth': 1995,
- 'yearnow': 2019,
- 'age': person['yearnow'] + person['yearofbirth']
- }
- class MyDict(dict):
- def __getitem__(self, item):
- return dict.__getitem__(self, item) % self
- dictionary = MyDict({
- 'user' : 'gnucom',
- 'home' : '/home/%(user)s',
- 'bin' : '%(home)s/bin'
- })
- print dictionary["home"]
- print dictionary["bin"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement