import help
placid
Bulkan at gmail.com
Mon Apr 10 23:55:31 EDT 2006
Scott David Daniels wrote:
> placid wrote:
> > I have the following class code for a Node for a Linked List, (saved in
> > node.py)
> >
> > class Node :
> > def __init__(self,element):
> > self.element = element
> > self.next = None
> >
> > then i have another module called LinkedList.py, with following code
> >
> > import sys
> > import node
> > def main():
> > print "Does nothin ATM, as it doesnt work"
> > main()
> >
> > the problem im having is that im getting NameError exception when i run
> > LinkedList.py "global name 'Node' is not defined"
> >
> > Does anyone know what the problem is here?
>
> I have trouble believing you. I suspect you are telling us what you
im not leaving anything out, im telling you what's happening
> think is happening, and leaving something vital out. In particular,
> cut and paste the traceback.
here it is!
Traceback (most recent call last):
File "LinkedList.py", line 7, in ?
main()
File "LinkedList.py", line 4, in main
n = Node("test")
NameError: global name 'Node' is not defined
>
> Here's another experiment, interactively do:
>
> import node
> print node.__file__
>>> import node
>>> print node.__file__
node.py
>
> Perhaps that will tell you something.
More information, im using Windows XP Pro, these two files are in same
directory...
>
> --Scott David Daniels
> scott.daniels at acm.org
More information about the Python-list
mailing list