Is this an ok thing to do in a class
Vincent Davis
vincent at vincentdavis.net
Tue May 18 01:21:32 EDT 2010
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)]
*Vincent Davis
720-301-3003 *
vincent at vincentdavis.net
my blog <http://vincentdavis.net> |
LinkedIn<http://www.linkedin.com/in/vincentdavis>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100517/fafd7e2f/attachment.html>
More information about the Python-list
mailing list