Need help with my 1st python program

Walter Brameld IV wb4REMOVE_THIS_TEXT at wbrameld4.name
Sat May 8 15:35:37 EDT 2010


Dave Luzius wrote:
> On Sat, 08 May 2010 19:02:42 +0000, Steven D'Aprano wrote:
> 
>> On Sat, 08 May 2010 18:52:33 +0000, Dave Luzius wrote:
>>
>>> Pleaser help me with this. Here's a copy of the program, but it keeps
>>> calling for me to define pressure.
>> That's because you haven't defined pressure.
>>
>> When Python tells you there is a bug in your program, it is almost
>> always correct.
>>
>>
>>> # A small program to fetch local barometer reading   from weather.com #
>>> and convert the value from   metric to imperial. # My first attempt at
>>> Python.
>>> #--------------------------------------------------------------------
>>> import urllib
>>>
>>> # next line does the fetching
>>> urllib.urlopen("http://xoap.weather.com/weather/local/USMI0060",
>>> pressure)
>> What is pressure? It is an undefined name. Where does pressure get its
>> value from?
> 
> Pressure is a term for barometric pressure, and is understood by Conky, 
> which this program is designed to work with, and is understood by 
> weather.com. But the value it passes to conky is metric, and I want it to 
> display in imperial.
> 
> What should I do....

You're passing in the value of pressure as the 'data' parameter to 
urllib.urlopen.  So...what is the value of pressure?  You haven't 
assigned any value to it before calling urlopen.  Therein lies the problem.



More information about the Python-list mailing list