I recently started studying Python, because of job opportunities, so today I decided to do an exercise using what I’ve been learning, I’m creating a bot for Telegram in Python, then I came across this situation: I need to call a variable that is in another file to the main file. to make the code cleaner, I separated the code into several files, there is a file to call the api, another that is the main file and another with the bot commands, to To be able to call the variables from the api, I created a function, but I don’t know if I can call the variables from within this function:
def botApi(SHINEAPI, bot):
SHINEAPI = decrypt_api_key()
bot = telebot.TeleBot(SHINEKUNAPI)
And I need to call the bot variable for this decorator:
@bot.message_handler(commands=['start'])
def respostaPadrao(mensagem):
....
Does anyone know if there is a way?
I’ve already tried to ask my technical course teacher and he still hasn’t answered and I’ve tried searching but I haven’t found anything that objectively answers my question…
Bruno Ciccarino is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.