#πŸ”’ Enum object is not equal to itself when it should be

4 messages Β· Page 1 of 1 (latest)

jaunty hearth
#

Hello! I have a py-cord code making a slash command, and then allowing only some inputs using an Enum object. Py-cord then, after the command has been ran, returns the enum object, along with the respective class variable. So if i chose names, it would return Properties.name. But as you can see in the console output(which is the 3 print statements accordingly), the first 2 lines show the enum object being identical, but when i compare them, it doesnt equal to true. I have been trying to solve this for quite some time now and i cant find a solution.
Here is the code in text form:

@bot.slash_command(guild_ids=supportedGuilds, description="Change a project's properties.")
async def change_project_properties(ctx, property: Option(Enum('Properties', ['name', 'finalkd', 'startdate', 'leader']), "Property", required=True)): #type: ignore
    current = Properties.name
    if property == current:
        await ctx.response.send_message("Success!")
        print("a")
    print(f"{property}: {type(property)}")
    print(f"{current}: {type(current)}")
    print(f"{property == current}")```
icy robinBOT
#

@jaunty hearth

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

icy robinBOT
#

@jaunty hearth

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.