global name 'class' is not defined - Python -
i defined class called parser
in file called parser.py
, parses test result....
import sys import re class parser: def __init__(self): pass def udp_parse(self, filename=""): # ... code on here
now, in main.py
. have:
from dbconn import * parser import * import os import subprocess def main() dbconn = dbconn() parse = parser() # more code here ... if __name__ == '__main__': main()
and i'm getting:
traceback (most recent call last): file "iperf.py", line 108, in <module> main() file "iperf.py", line 49, in main parse = parser() nameerror: global name 'parser' not defined
parser.py
in same directory dbconn.py
, main.py
. dbconn()
works without problem, i'm not understanding why parser()
can't work ...
parser existing python module. use different file name (not parser.py) or insert path in sys.path before stdlibs.
import sys sys.path.insert(0,'parser/directory') parser import *
Comments
Post a Comment