basic class question..
Diez B. Roggisch
deets at nospam.web.de
Sun Nov 15 07:52:55 EST 2009
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)
Thes scopes insied a class are only the method-locals (to which the
parameters count of course), and globals.
Diez
More information about the Python-list
mailing list