[pyar] Consulta sobre Pattern Registry

Facundo Batista facundobatista en gmail.com
Mie Oct 20 16:46:28 ART 2010


2010/10/20 Leonardo Vidarte <lvidarte en gmail.com>:

> El uso sería:
>
> # archivo1.py
> from registry import Registry
> Registry.set('foo', 1)
> Registry.set('bar', 2)
>
> # archivo2.py
> from registry import Registry
> if 'foo' in Registry.keys():
>    print Registry.get('foo')

KISS:

$ cat registry.py
registry = {}

$ cat arch1.py
from registry import registry
registry['foo'] = 1
registry['bar'] = 2
import arch2

$ cat arch2.py
from registry import registry
print registry['foo']

$ python arch1.py
1

Slds.

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/



More information about the pyar mailing list