A basic Python program to pull data from the cloud
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.
Accessing the web service
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
Newicon 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...