Attributes in privates methods

Diez B. Roggisch deets at nospam.web.de
Fri Feb 19 10:21:51 EST 2010


Am 19.02.10 16:08, schrieb Yasser Almeida Hernández:
> Hi all.
>
> I have a class with the attribute 'log_file', opened out of the class:
> class ProteinCluster:
> def __init__(self,cluster_name,log_file):
> ...
> self.log_file = log_file
> ...
> Then i have a private method which write in the log_file:
> def _read_structure(self, pdb_code):
> ...
> ...
> self.log_file.write('blablabla')
> ...
> ...
> When i run the script, it raises the error:
> AttributeError: ProteinCluster instance has no attribute 'log_file'
>
> My question is, the class attributes are valids in private methods, like
> in publics methods?

There is no semantical difference there, you must have some other error.

Diez



More information about the Python-list mailing list