-1

Possible Duplicate:
Dynamically set local variable in Python

I tried to execute this :

        # the request send a number and its ok, the variable have good informations.
        test = request.POST[member.user.username]

        # SyntaxError at ***here***, can't assign to operator
        group%d % test = member.user.username

I have tried also :

        test = request.POST[member.user.username]
        group%d = member.user.username % test

And :

        test = request.POST[member.user.username]
        group%d = member.user.username % (test)

Any idea for the syntax ?

Community
  • 1
  • 1
nlassaux
  • 2,335
  • 2
  • 21
  • 35

1 Answers1

0

You can use dictionnary to do this:

test = request.POST[member.user.username]
d={}
d['group'+str(test)]= member.user.username

Maybe, there is a better way to do that, but I only know this one.

kevin
  • 198
  • 1
  • 6