I'm not sure if this is more neat, but:
class MyClass:
def __init__(self):
for v in ('time', 'pos', 'vel', 'acc', 'rot', 'dyn'):
exec("self.%s = 0" % v)
As SilentGhost suggested, you should probably put them in a reasonable data structure, such as a tuple, for example.
class MyClass:
def __init__(self):
self.values = 20*(0,)
or, you can use the dictionary:
class MyClass:
def __init__(self):
self.data = {}
for v in ('time', 'pos', 'vel', 'acc', 'rot', 'dyn'):
self.data[v] = 0
source
share