getattr(foo, 'foobar') not the same as foo.foobar?

Erik Max Francis max at alcyone.com
Thu Mar 13 19:30:49 EDT 2008


Dave Kuhlman wrote:

> Basically, the above code is saying that foo.foobar is not the same as
> getattr(foo, 'foobar').

Python promises that the behavior is the same.  It does not promise that 
the _objects_ will be the same, which is what `is` determines.  That is, 
you're not doing a useful test here.

In Python, bound methods are dynamically generated.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   There is no present or future; only the past, happening over and over
    again, now. -- Eugene O'Neill



More information about the Python-list mailing list