basic class question..

Diez B. Roggisch deets at nospam.web.de
Sun Nov 15 09:20:49 EST 2009


Diez B. Roggisch schrieb:
> Pyrot schrieb:
>> class rawDNA:
>>     import string
> 
> Importing here is unusual. Unless you have good reasons to do so, I 
> suggest you put the imports on top of the file.
> 
>>     trans = string.maketrans("GATC","CTAG")
>>
>>
>>     def __init__(self, template = "GATTACA"):
>>         self.template = template  //shouldn't this make "template"
>> accessible within the scope of "rawDNA"??
> 
> No.
>>
>>
>>     def noncoding(self):
>>         print template.translate(trans)  //
> 
> This needs to be
> 
>   print self.template.translate(trans)

Ah, sorry, that should have been

   self.template.translate(self.trans)

Diez



More information about the Python-list mailing list