UnboundLocalError when accessing location.is_authorised() inside function
When I try:
import location def get_direction(): if location.is_authorized(): #do something
I get an UnboundLocalError: local variable 'location' referenced before assignment.
But the similar code works with other modules e.g:
import time def get_time_diff(): if time.time() > 1234: #do something
How can I get around the UnboundLocalError? Importing the location module inside the function works, but I don't want to have to import it within each function that uses location.
Maybe I'm missing something obvious so any suggestions are appreciated!