Closed GoogleCodeExporter closed 8 years ago
[deleted comment]
After some thought, I think it's better to have no value when NOAA isn't
reporting the value
for tag in data_structure:
try:
weather_data[tag] = current_observation.getElementsByTagName(tag)[0].firstChild.data
except IndexError:
pass
Original comment by drdr...@gmail.com
on 26 Jun 2009 at 6:57
Thank you for pointing to this issue, drdrang.
It is necessary to fix the issue in all functions.
> After some thought, I think it's better to have no value when NOAA isn't
reporting
the value
Why do you think so?
Original comment by qet...@gmail.com
on 29 Jun 2009 at 11:34
According to the Zen of Python:
Errors should never pass silently.
Unless explicitly silenced.
It's a matter of convention. In Python, it's most common to raise an
exception when a program tries to access a piece of data that isn't
there, and Python programmers expect to use try/except blocks to
handle exceptions. If pywapi puts empty strings into the dictionary,
programmers won't be able to use try/except to distinguish the
dictionary entries that are there from those that aren't.
If your library were written in Perl, I would be making the opposite
argument--Perl programmers expect unknown hash keys and list indexes
to return empty values. In my first message, I was thinking more like
a Perl programmer.
By the way, you may be interested in this post
http://www.leancrew.com/all-this/2009/06/new-weather-script-for-geektool/
in which I describe a use of pywapi.
Original comment by drdr...@gmail.com
on 29 Jun 2009 at 7:10
Added.
Original comment by qet...@gmail.com
on 10 Aug 2009 at 8:34
Original issue reported on code.google.com by
drdr...@gmail.com
on 16 Jun 2009 at 2:48