I don't know if I'd recommend stretching the python syntax so far but the getattr class method will work. It is invoked whenever you access a member that is not in a class's dictionary, so you need to be sure that "X" is not a class member, use something like "_X" instead and then use a class structure like this:
class a(object):
def _hi(self):
print "hello"
def __getattr__(self, val):
a.__dict__["_" + val](self)
>>> b = a()
>>> b.hi
hello
***EDIT: dealing with the dot syntax
class A(object):
def __init__(self, call_tree=None):
self.call_tree = call_tree
def __getattr__(self, val):
if self.call_tree:
new_call_tree = '.'.join([self.call_tree, val])
else:
new_call_tree = val
return A(call_tree=new_call_tree)
def __call__(self, *args, **kwargs):
url = 'https://api.flickr.com/?function={}'.format(self.call_tree)
print url
>>> b = A()
>>> b.hi.mom()
https://api.flickr.com/?function=hi.mom
>>> b.hi.dad()
https://api.flickr.com/?function=hi.dad