More elegant way of declaring multiple variables at the same time

Trufa picture Trufa · Mar 31, 2011 · Viewed 285.4k times · Source

To declare multiple variables at the "same time" I would do:

a, b = True, False

But if I had to declare much more variables, it turns less and less elegant:

a, b, c, d, e, f, g, h, i, j = True, True, True, True, True, False, True ,True , True, True

Is there a better / elegant / convenient way to do this?

This must be very basic, but if I do used a list or a tuple for storing the variables, how would I have to approach so that I would be helpful since:

aList = [a,b]

Is not valid, I would have to do:

a, b = True, True

Or what am I missing?

Answer

Shariq picture Shariq · Jul 30, 2012
a, b, c, d, e, g, h, i, j = (True,)*9
f = False