getattr(foo, 'foobar') not the same as foo.foobar?
Dave Kuhlman
dkuhlman at rexx.com
Thu Mar 13 19:29:11 EDT 2008
Arnaud Delobelle wrote:
>
> 4. Both points above follow from the fact that foo.bar is really a
> function call that returns a (potentially) new object: in fact what
> really happens is something like
Arnaud and Imri, too -
No. foo.bar is *not* really a function/method call.
>
> Foo.__dict__['bar'].__get__(foo, Foo).
>
> So every time foo.bar is executed an object is (or may be) created,
> with a new id.
>
> HTH
I appreciate the help, but ...
Actually, it does not help, because ...
My understanding is that foo.bar does *not* create a new object. All it
does is return the value of the bar attribute of object foo. What new
object is being created?
If I have:
class Foo(object):
def bar(self): pass
And I do:
foo = SomeClass()
then:
foo.bar
should return the same (identical) object everytime, no? yes?
I'm still confused.
- Dave
>
> --
> Arnaud
--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
More information about the Python-list
mailing list