Re: Need help with my 1st python program
On Sat, 08 May 2010 18:52:33 +, 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? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with my 1st python program
On Sat, 08 May 2010 19:02:42 +, Steven D'Aprano wrote: On Sat, 08 May 2010 18:52:33 +, 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with my 1st python program
Dave Luzius wrote: On Sat, 08 May 2010 19:02:42 +, Steven D'Aprano wrote: On Sat, 08 May 2010 18:52:33 +, 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with my 1st python program
On Sat, May 8, 2010 at 3:13 PM, Dave Luzius dluz...@comcast.net wrote: 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 -- Don't tell us what pressure is. Tell Python. urllib.urlopen(http://xoap.weather.com/weather/local/USMI0060;, pressure) What do you think this line does? Because it does absolutely nothing. Assuming pressure is defined It creates a file-like object connected to that URL. But because that file-like object is never assigned to anything, it's reference count drops to 0 and it's immediately closed and deleted. You have to 1) Assign the file-like object to some name. 2) Read the data from the file-like object 3) convert the string you read from the file-like object into a float 4) use the float to do math Python is succinct, but it isn't magic. Just like every other programming language, it can't guess what you want it to do. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with my 1st python program
On Sat, 08 May 2010 19:13:12 +, Dave Luzius wrote: 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. I know what pressure is in English. What is it in your program? When the Python compiler sees the word pressure, what do you expect it to do? What should I do Perhaps you should start with a few simple tutorials and introductions to programming before tackling this program. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with my 1st python program
I think what is not clear by what is being said is that you have passed in pressure and not 'pressure'. The first is undefined, pressure = 1 would define it. Where as 'pressure' is a string type. On Sat, May 8, 2010 at 1:35 PM, Walter Brameld IV wb4remove_this_t...@wbrameld4.name wrote: Dave Luzius wrote: On Sat, 08 May 2010 19:02:42 +, Steven D'Aprano wrote: On Sat, 08 May 2010 18:52:33 +, 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. -- http://mail.python.org/mailman/listinfo/python-list *Vincent Davis 720-301-3003 * vinc...@vincentdavis.net my blog http://vincentdavis.net | LinkedInhttp://www.linkedin.com/in/vincentdavis -- http://mail.python.org/mailman/listinfo/python-list