En Thu, 06 Mar 2008 22:56:33 -0200, <[EMAIL PROTECTED]> escribió: > On Mar 6, 5:35 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: >> >> p = P() >> print p.bar.func_name # -> bar >> p.bar.im_func.anotherattribute = 1 >> print p.bar.anotherattribute # -> 1 >> >> (the attribute must be set on the *function* itself if you want it to >> be >> somewhat persistent; methods are usually volatile objects) > > You read my mind.
You could try to write in a way that reading your mind isn't necesary... > I was just getting: > assert p.bar is p.bar > and failing. > > But if you set them on im_func, instances don't have their own. Instances don't have their own methods either. What do you actually want to do? If you need a method with per-instance attributes, that looks like another object to me. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list