[Tutor] Issue with classes

Andreas Perstinger andipersti at gmail.com
Tue Jun 12 10:54:41 CEST 2012


On Tue, 12 Jun 2012 09:07:13 +0100 
Bod Soutar <bodsda at googlemail.com> wrote:

> 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

You define "cf" only inside your "main" function, so the "cliArgs"
class doesn't know about it. So either make "cf" global (bad) or change
your "cliArgs" class so that it takes a "cheatFile" object as an
argument and you would call it like:

ca = cliArgs(cf)

HTH, Andreas 


More information about the Tutor mailing list