Referencing vars, methods and classes by name

greg greg at cosc.canterbury.ac.nz
Thu Feb 8 18:52:36 EST 2007


Gabriel Genellina wrote:
> On 8 feb, 05:51, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> 
> > "Gabriel Genellina" <gagsl... at yahoo.com.ar> writes:
> >
> > > Surely you meant to say getattr(obj, a)()
> >
> > Yeah, darn.  Counterintuitive.
> 
> A generic function helps on using it on objects of any kind - like
> len()
> Perhaps it was more important with old style classes.

It also avoids intruding on the method namespace of the
object. That's important -- I like the way that the
namespace of a brand-new class is a blank slate, apart
from the double-underscore names.

--
Greg



More information about the Python-list mailing list