[Tutor] #NameError: global name is not defined

Kent Johnson kent37 at tds.net
Thu May 12 12:04:58 CEST 2005


Aaron Elbaz wrote:
> Hi,
> 
> I'm having difficulty understanding why the following code doesn't work:
> 
> 
> getfr.py
> #import pymetar
> #
> #class wReport:
> #    def __init__(self,metarcode="CYYC"): #weather for calgary INTL
> #        self.METARCODE=metarcode
> #        rf=pymetar.ReportFetcher(self.METARCODE)
> #        rep=rf.FetchReport()
> #        pr=rp.ParseReport(rep)
> #    def getRep()
> #        return pr.getFullReport

You never assign to rp so it is undefined, which is what the error message is telling you.

Looking at the pymetar example you are missing the line
rp=pymetar.ReportParser()

Kent



More information about the Tutor mailing list