Local variables in a function are not visible as attributes on that function. For a nested scope, just use the name directly:
def add():
def addFilm():
db = open(r"C:\Users\PC\Desktop\db.txt", "a+")
global film
film = enter.get()
db.write(film + "\n")
db.flush()
db.close()
Here enter
will be attached to addFilm()
as a closure, and Python will attach the parent scope enter
to the function for later dereferencing. You do need to store the returned value; I guessed that you wanted to assign it to film
here.