#!/usr/bin/env python
# -*- coding: utf-8 -*-
DATA = {
'wall': (1,2,3),
'messages': (4,5,6),
'photos': (7,8,9),
'videos': (10,11,12),
}
get = lambda name: DATA[name.replace('get_','')]
class VK(object):
__all__ = ('get_wall', 'get_messages',
'get_photos', 'get_videos')
def __init__(self):
self.x = 2
def __getattr__(self, name):
if name in self.__all__:
return lambda: get(name)
else:
return getattr(name)
def main():
v = VK()
print v.get_photos()
print v.get_wall()
print v.x
if __name__ == '__main__':
main()
IyEvdXNyL2Jpbi9lbnYgcHl0aG9uCiMgLSotIGNvZGluZzogdXRmLTggLSotCgpEQVRBID0gewogICAgJ3dhbGwnOiAoMSwyLDMpLAogICAgJ21lc3NhZ2VzJzogKDQsNSw2KSwKICAgICdwaG90b3MnOiAoNyw4LDkpLAogICAgJ3ZpZGVvcyc6ICgxMCwxMSwxMiksCn0KCmdldCA9IGxhbWJkYSBuYW1lOiBEQVRBW25hbWUucmVwbGFjZSgnZ2V0XycsJycpXQoKY2xhc3MgVksob2JqZWN0KToKICAgIF9fYWxsX18gPSAoJ2dldF93YWxsJywgJ2dldF9tZXNzYWdlcycsCiAgICAgICAgICAgICAgICdnZXRfcGhvdG9zJywgJ2dldF92aWRlb3MnKQoKICAgIGRlZiBfX2luaXRfXyhzZWxmKToKICAgICAgICBzZWxmLnggPSAyCgogICAgZGVmIF9fZ2V0YXR0cl9fKHNlbGYsIG5hbWUpOgogICAgICAgIGlmIG5hbWUgaW4gc2VsZi5fX2FsbF9fOgogICAgICAgICAgICByZXR1cm4gbGFtYmRhOiBnZXQobmFtZSkKICAgICAgICBlbHNlOgogICAgICAgICAgICByZXR1cm4gZ2V0YXR0cihuYW1lKQoKZGVmIG1haW4oKToKICAgIHYgPSBWSygpCgogICAgcHJpbnQgdi5nZXRfcGhvdG9zKCkKICAgIHByaW50IHYuZ2V0X3dhbGwoKQogICAgcHJpbnQgdi54CgppZiBfX25hbWVfXyA9PSAnX19tYWluX18nOgoJbWFpbigp