Re: along the lines, hash and obj. id.

2008-03-02 Thread castironpi
On Feb 27, 5:38 pm, [EMAIL PROTECTED] wrote: > On Feb 27, 4:16 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > > For a), you use something like obj.a.somemethod(). "obj.a" still refers to > > the same object, even if it changed internally; if obj.a and foo.bar both > > were refering to the same objec

Re: along the lines, hash and obj. id.

2008-02-27 Thread castironpi
On Feb 27, 4:16 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 26 Feb 2008 05:58:52 -0200, <[EMAIL PROTECTED]> escribió: > > > It works to keep a reference to the object, then access the member > > again. If your only reference to the object is the member itself, > > obj.a= {} breaks

Re: along the lines, hash and obj. id.

2008-02-27 Thread Gabriel Genellina
En Tue, 26 Feb 2008 05:58:52 -0200, <[EMAIL PROTECTED]> escribió: > It works to keep a reference to the object, then access the member > again. If your only reference to the object is the member itself, > obj.a= {} breaks d, but obj.a.clear() keeps it alive. > > In the case of immutables, there i

Re: along the lines, hash and obj. id.

2008-02-26 Thread castironpi
On Feb 26, 1:11 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Mon, 25 Feb 2008 23:58:52 -0800 (PST), [EMAIL PROTECTED] declaimed > the following in comp.lang.python: > > > The generic solution involves a second level of indirection: tuple* d= > > &obj.a.  I can't land a clean solution to it

Re: along the lines, hash and obj. id.

2008-02-26 Thread castironpi
On Feb 25, 11:30 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Mon, 25 Feb 2008 17:55:18 -0800 (PST), [EMAIL PROTECTED] declaimed > the following in comp.lang.python: > > > I'd like to do this: > > > a= list( range( 5 ) ) > > assert a== [ 0, 1, 2, 3, 4 ] > > for i in ref( a ): > >     i.ref

along the lines, hash and obj. id.

2008-02-25 Thread castironpi
I'd like to do this: a= list( range( 5 ) ) assert a== [ 0, 1, 2, 3, 4 ] for i in ref( a ): i.ref*= 2 a= deref( a ) assert a== [ 0, 2, 4, 6, 8 ] In the for loop, i objects maintain their identities, while still being reassigned. The first way I think of is this: class Ref: def __init__(