Re: [pyar] Problemas de memory leak

Página superior
Adjuntos:
+ (text/plain)
+ (text/html)
+ (text/plain)
Eliminar este mensaje
Responder a este mensaje
Autor: Ale
Fecha:  
A: Python Argentina
Asunto: Re: [pyar] Problemas de memory leak
2010/10/5 Roberto Alsina <>

> On Tuesday 05 October 2010 15:51:29 John Rowland Lenton wrote:
> > > Hice así:
> > >
> > >         def __init__(self):
> > >             self.__getattr__ = self.__getitem__
> > >             self.__setattr__ = self.__setitem__
> > >             self.__delattr__ = self.__delitem__

> > >
> > >
> > > Y quedó andando bien.
> >
> > de curioso: por qué en la instancia y no en la clase?
>
> Ya sabiendo que en la instancia no funciona:
>
> >>> class C(dict):
> ...     __getattr__=__getitem__
> ...
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "<stdin>", line 2, in C
> NameError: name '__getitem__' is not defined

>



Pregunta: No queres entonces esto?
In [1]: class C(dict):
   ...:     __getattr__ = dict.__getitem__
   ...:
   ...:


In [2]: c = C()

In [3]: c['a'] = 42

In [4]: c.a
Out[4]: 42



> _______________________________________________
>




> pyar mailing list
> http://listas.python.org.ar/listinfo/pyar
>
> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>




--
Ale.
_______________________________________________
pyar mailing list
http://listas.python.org.ar/listinfo/pyar

PyAr - Python Argentina - Sitio web: http://www.python.org.ar/