class rawDNA:
        import string
        trans = string.maketrans("GATC","CTAG")


        def __init__(self, template = "GATTACA"):
                self.template = template  //shouldn't this make "template"
accessible within the scope of "rawDNA"??


        def noncoding(self):
                print template.translate(trans)  //
>>>test = rawDNA()

>>>test.noncoding()

Traceback (most recent call last):
  File "<pyshell#29>", line 1, in <module>
    test.noncoding()
  File "<pyshell#25>", line 7, in noncoding
    print template.translate(trans)
NameError: global name 'template' is not defined

I'm curious .. what am I doing wrong??

P.S

class rawDNA:
        import string
        trans = string.maketrans("GATC","CTAG")
        def __init__(self, template = "GATTACA"):
                self.template = template
        def noncoding(self):
                print self.template.translate(trans)

this works as intended.

Thanks in advance
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to