[Tutor] Issue with classes

Bod Soutar bodsda at googlemail.com
Tue Jun 12 10:59:56 CEST 2012


On Jun 12, 2012 9:56 AM, "Andreas Perstinger" <andipersti at gmail.com> wrote:
>
> 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
>

Thanks, that makes sense. I'll give it a go.

Cheers,
Bodsda  _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120612/c93e98f4/attachment.html>


More information about the Tutor mailing list