eval of a private attribute

BRINER Cedric work at infomaniak.ch
Thu Mar 21 02:45:13 EST 2002


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

Unfortunately this example is not working:


class CObsFile:
  __user="~briner/big/usr.rdb"
  __location="~genevay/system/location"
  def get(self,var):
    tobeEval ='self.__'+var
    print 'toBeval: '+tobeEval
    p=eval(tobeEval)
    print 'Evaluated: '+p
    return p

p=CObsFile()
p.get('user') 

any idea why



More information about the Python-list mailing list