How do I update the value of a variable within another script?

Asked

Viewed 25 times

0

Basically to illustrate better, I’m supposed to have a.py file that has the following content:

token = ''

I created the update_file.py that has the goal of updating the token variable to another value where it necessarily has to be an input. My question is how would the file update.py.

1 answer

0

A solution would be:

import arquivo

new_token = input("Entre com seu token: ")

arquivo.token = new_token

print(arquivo.token)

But that only works at runtime. When the program finishes the token returns to the default value which in the case is empty

Browser other questions tagged

You are not signed in. Login or sign up in order to post.