eval of a private attribute

Skip Montanaro skip at pobox.com
Thu Mar 21 09:24:37 EST 2002


    Cedric> I'd like to create a method which will be able to get any
    Cedric> attribute of the class.

Why use eval?  Why not simply

    p = getattr(self.__class__, var)

?  The first arg restricts you to fetching class variables.  You could also
use 'self' there I suppose.

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)




More information about the Python-list mailing list