0

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()
0

1 Answer 1

3

I would simply create a dictionary that maps the username to the object:

states = {}
username = data.get('username')
state[username] = ExampleState()
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.