Wednesday, February 11, 2015

Announcing Padme v1.0


I've just released Padme (named after the Star Wars character).

Padme is an implementation of mostly transparent proxy class for Python. What is unique about it is the ability to proxy objects of any class and to selectively un-proxy any method in a subclass. Check out the documentation for more examples, I'll post a quick one here:

>>> from padme import proxy
>>> pets = ['cat', 'dog', 'fish']
>>> pets_proxy = proxy(pets)
>>> pets_proxy
['cat', 'dog', 'fish']
>>> pets_proxy.append('rooster')
>>> pets
['cat', 'dog', 'fish', 'rooster']
>>> from padme import unproxied
>>> class censor_cat(proxy):
...     @unproxied
...     def __repr__(self):
...         return super(censor_cat, self).__repr__().replace('cat', '***') 
>>> pets_proxy = censor_cat(pets)
>>> pets_proxy
['***', 'dog', 'fish', 'rooster']

At the same time, I'd like to ask interested parties to contribute and port Padme to Python 2.7, so that it can be universally useful to everyone. Please have a look at the contribution guide if you are interested.

No comments:

Post a Comment