I have an object of class and want to re initialize the object by a function
So I am writing a discord bot and there's one object that i want to be recreated every time the bot gets a command.
import discord
client = discord.Client()
obJ_class = bot_friendly.Exec() # this creates the object and everything works fine
now
@client.event
async def on_message(message):
if message.content.startswith("&&exit"):
await message.channel.send("Exiting")
await client.close()
print("Successfully logged out")
if message.content.startswith("&&update"):
await message.channel.send("Wait a few seconds")
obJ_class = bot_friendly.Exec()
here the error is Shadows name 'obJ_class' from outer scope
I would like to know if this is even doable or should i just make another function that does what the __init__(self):
does but just name it update():