N
Nathan Harmston
Hi All,
I ve got a single module which I m using to contain a lot of
dictionaries, constants, general information, which are used by
various other modules. However I can't seem to access them:
in data.py
_SEQTYPE_DNA = 0
_SEQTYPE_RNA = 1
_SEQTYPE_PROT = 2
_seqType = { "DNA":_SEQTYPE_DNA, "RNA":_SEQTYPE_RNA, "PROTEIN":_SEQTYPE_PROT }
but in test.py
from data import *
class Test(object):
def __init__(self, type):
self.type = _seqType[type]
def test(self):
return self.type
t = Test("DNA")
print t.test()
File "test.py", line 24, in __init__
self.type = _seqType[type]
NameError: global name '_seqType' is not defined
I think I m doing something incredibly wrong/stupid here....
Can anyone help?
Many Thanks
Nathan
PS. I was wondering if the use of a data module to store constants and
dictionaries is good design??? or not?
I ve got a single module which I m using to contain a lot of
dictionaries, constants, general information, which are used by
various other modules. However I can't seem to access them:
in data.py
_SEQTYPE_DNA = 0
_SEQTYPE_RNA = 1
_SEQTYPE_PROT = 2
_seqType = { "DNA":_SEQTYPE_DNA, "RNA":_SEQTYPE_RNA, "PROTEIN":_SEQTYPE_PROT }
but in test.py
from data import *
class Test(object):
def __init__(self, type):
self.type = _seqType[type]
def test(self):
return self.type
t = Test("DNA")
print t.test()
File "test.py", line 24, in __init__
self.type = _seqType[type]
NameError: global name '_seqType' is not defined
I think I m doing something incredibly wrong/stupid here....
Can anyone help?
Many Thanks
Nathan
PS. I was wondering if the use of a data module to store constants and
dictionaries is good design??? or not?