I am trying to build an assistant using python. And it keep showing the error "location.condition is not callable pylint(not-callable)" & "location.forecast is not callable pylint(not-callable)"
elif 'current weather in' in command:
reg_ex = re.search('current weather in (.*)', command)
if reg_ex:
city = reg_ex.group(1)
weather = Weather(unit=Unit.CELSIUS)
location = weather.lookup_by_location(city)
condition = location.condition()
TalkToMe('The Current weather in %s is %s.'
'The tempeture is %d.1 C degree' %(city, condition.text(),
(int(condition.temp))))
elif 'weather forecast in' in command:
reg_ex = re.search('weather forecast in (.*)', command)
if reg_ex:
city = reg_ex.group(1)
weather = Weather()
location = weather.lookup_by_location(city)
forecasts = location.forecast()
for i in range(0,3):
TalkToMe("On %s will it %s."
'The maximum temperture will be %d.1 C degree.'
'The lowest temperature will be %d.1 C degrees.' % (forecasts[i].date(), forecasts[i].text(), (int(forecasts[i].high)), (int(forecasts[i].low))))
It should tell the weather condition or the weather forecast
The example at https://pypi.org/project/weather-api/ shows:
weather = Weather(unit=Unit.CELSIUS)
location = weather.lookup_by_location('dublin')
condition = location.condition
print(condition.text)
However, you are doing lookup.condition()
. The parentheses cause Python to "call" lookup.condition
, i.e. requiring it to be callable.
Note that pylint is a static code analyzer. It tries to warn you in advance for problems in your code, so you can fix them before actually running the program. A static code analyzer is not always correct, but in this case it seems to be. Removing the parentheses should solve the problem.