"""resolution for Python issue 15289""" import UserDict class ClassAsDict(type, UserDict.UserDict): """\ This is a metaclass that allows you to access class data by treating the class as a dictionary.""" def __new__(mcs, name, bases, dict): """Unfortunately, we need to manually add 'data' to the class dict.""" dict['data'] = {} return type.__new__(mcs, name, bases, dict) class Alias(object): """\ A decorator to track functions via special names that aren't limited to Python's naming rules. """ __metaclass__ = ClassAsDict def __init__(self, str=None): self.str = str def __call__(self, func): if self.str: str = self.str else: str = func.__name__ # Here we have a choice of ways to save our data in the class. self.__class__[str] = func # Using the UserDict fuctionality. ## self.data[str] = func # Requires us to know how UserDict works. return func @Alias("f'") def f_prime(): pass print Alias["f'"]