[Tutor] variable existence q

Clayton Kirkwood crk at godblessthe.us
Sat Aug 15 22:51:50 CEST 2015


10 top_directory = "/users/Clayton/Pictures"

    def override_defaults():
56     return( top_directory, filetypes, target_directory )
     
80 top_directory, filetypes, target_directory = override_defaults()


  File "C:/Users/Clayton/python/find picture duplicates/find picture
duplicates", line 80, in <module>
    top_directory, filetypes, target_directory = override_defaults()
  File "C:/Users/Clayton/python/find picture duplicates/find picture
duplicates", line 56, in override_defaults
    return( top_directory, filetypes, target_directory )
UnboundLocalError: local variable 'top_directory' referenced before
assignment

I am facing the above error:
10 occurs first
80 then runs
56 appears to not work, the function logically does nothing
I thought that variables in the main were visible to defined functions in
the same file, as long as the assignment occurs physically before use. When
debugging, inside of override_defaults sees the correct value.
What am I not seeing?

TIA,
Clayton



More information about the Tutor mailing list