Now it's time to add what we learned from the previous chapters. Let's revisit the CurrentWeather class from Chapter 4, Subscribing to Web Services. We will rename it WeatherData, as this name is more appropriate for this project, and change it a little bit.
- 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, Unitimport timeclass WeatherData: temperature = 0 weather_conditions = '' wind_speed = 0 city = '' def __init__(self, city): self.city = city weather = Weather(unit = Unit.CELSIUS) lookup = weather.lookup_by_location(self.city) self.temperature = lookup.condition.temp self.weather_conditions = lookup.condition.text ...