Vincent Davis wrote:
Just wondering if there is a problem with mixing a dictionary into a class like this. Everything seems to work as I would expect.

class foo(object):
    def __init__(self, x):
        self.letter = dict(a=1,b=2,c=3)
        self.A=self.letter['a']
        self.x=self.letter[x]

 >>> afoo = foo('b')
 >>> afoo.x
2
 >>> afoo.A
1
 >>> afoo.letter['a']
1
 >>> afoo.letter.items()
[('a', 1), ('c', 3), ('b', 2)]

Do you expect afoo.letter[x] to always be afoo.x?  Because they aren't:

>>> afoo.A = 9
>>> afoo.letter['a']
1

~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to