getattr function

Alwyn Schoeman alwyns at prism.co.za
Fri Dec 17 06:24:45 EST 1999


Hi,

Could someone please explain this function to me? Specifically as
it relates to use in classes and overloading?

Say I've got my own listthingy class without a sort, if I now do
X.sort() I can see that a method in my class which looks like
def __getattr__(self, name),   that sort is probably the name
parameter.  But how does it know that it must do a list type sort
or does this
work just because sort is kindof generic?

def __getattr__(self, name):
        return getattr(self.data,name)

for the above.

--
~~~~~~~~~~~~~~
Alwyn Schoeman
Systems Engineer
Prism Secure Solutions







More information about the Python-list mailing list