Have you thought about using better data structures? Like dictionaries i.e.
class Board(object):
def __init__(self):
self.dict = {"one":"1", "two":"2", "three":"3"}
And then you could do something like:
>>> a = Board()
>>> a.dict
{'three': '3', 'two': '2', 'one': '1'}
>>> for element in a.dict:
a.dict[element] = element+"x"
>>> a.dict
{'three': 'threex', 'two': 'twox', 'one': 'onex'}
>>> a.dict["one"] = "1"
>>> a.dict
{'three': 'threex', 'two': 'twox', 'one': '1'}
The solution you're looking for is also possible (most likely with some very very weird getattrs etc... and I wouldn't really recommend it.
Edit1 It turns out (after checking) that your class attributes will be stored in a object.__dict__ anyhow. SO why not use your own.
Just also to clarify it is possible emulating container objects with your own class by defining __getitem__ and __setitem__ methods like bellow:
class Board(object):
def __init__(self):
self.dict = {"one":"1", "two":"2", "three":"3"}
def __getitem__(self,key):
return self.dict[key]
def __setitem__(self, key, value):
self.dict[key] = value
Which means you don't have to keep writing a.dict everywhere and can pretend your class is the container (dict) like bellow:
>>> a = Board()
>>> a.dict
{'three': '3', 'two': '2', 'one': '1'}
>>> a["one"]
'1'
>>> a["one"] = "x"
>>> a.dict
{'three': '3', 'two': '2', 'one': 'x'}