In Chapter 11, Writing Python Programs Using Raspberry Pi, we introduced a package called weather-api
that allows us to access the Yahoo! Weather web service. In this section, we will wrap up the Weather
object from the weather-api
package in our own class. We will reuse the name CurrentWeather
for our class. After testing out our CurrentWeather
class, we will utilize the Sense Hat Emulator in Raspbian and build a weather information ticker.
We will start out by modifying our CurrentWeather
class to make web service calls to Yahoo! Weather through the weather-api
package:
- Open up Thonny from
Application Menu
|Programming
|Thonny Python IDE
. - Click on the
New
icon to create a new file. - Type the following:
from weather import Weather, Unit class CurrentWeather: temperature = '' weather_conditions = '' wind_speed = '' city = '' def __init__(self, city): self.city = city weather...