[Python] Create a Class object using the username from incoming data

Discussão em 'Python' iniciado por Stack, Março 25, 2025.

  1. Stack

    Stack Membro Participativo

    Python newbie here:

    I have a

    class ExampleState:
    ...


    My purpose is to create a class object unique to every user. I get the username from my client flutter app in django.

    So, instead of

    state = ExampleState()


    it should be

    state_Derek = ExampleState()
    state_Brian = ExampleState()
    ...


    In my django views,

    I have

    username = data.get('username')


    I now need to create a class Object based on the username above.

    How do I create a class object like

    state_(username fetched from above) = ExampleState()

    Continue reading...

Compartilhe esta Página