[Tutor] Issue with classes

Bod Soutar bodsda at googlemail.com
Tue Jun 12 10:07:13 CEST 2012


Hi,

I am having some difficulty calling a class method from a different class.
When I run the attached script like this "python cheatsheet.py --list"

C:\>python cheatsheet.py --list
done
here?
Traceback (most recent call last):
  File "cheatsheet.py", line 167, in <module>
    main()
  File "cheatsheet.py", line 165, in main
    ca.parseArgs()
  File "cheatsheet.py", line 39, in parseArgs
    self.argList()
  File "cheatsheet.py", line 96, in argList
    handle = cf.load()
NameError: global name 'cf' is not defined


So the traceback points to the issue being on line 96, specifically the
call to cf.load(). cf.load() (line 147) is part of the cheatFile class
(line 125), and is instantiated with cf = cheatFile() (line 161)

I confess I don't know anything about classes really so I'm probably doing
something stupid, but can anyone point me in the right direction?

Thanks,
Bodsda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120612/d1e79e91/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cheatsheet.py
Type: application/octet-stream
Size: 4238 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20120612/d1e79e91/attachment-0001.obj>


More information about the Tutor mailing list