Re: Is this an ok thing to do in a class
On 18 May 2010 06:21:32 UTC+1, Vincent Davis vinc...@vincentdavis.net 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. No problem at all AFAIC. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this an ok thing to do in a class
Simon Brunning a écrit : On 18 May 2010 06:21:32 UTC+1, Vincent Davis vinc...@vincentdavis.net 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. No problem at all AFAIC. OP didn't show up on c.l.py, so too bad you snipped the relevant code snippet... -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this an ok thing to do in a class
Thanks for the feed back Vincent On Tue, May 18, 2010 at 8:50 AM, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: Simon Brunning a écrit : On 18 May 2010 06:21:32 UTC+1, Vincent Davis vinc...@vincentdavis.net 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. No problem at all AFAIC. OP didn't show up on c.l.py, so too bad you snipped the relevant code snippet... -- http://mail.python.org/mailman/listinfo/python-list *Vincent Davis 720-301-3003 * vinc...@vincentdavis.net my blog http://vincentdavis.net | LinkedInhttp://www.linkedin.com/in/vincentdavis -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this an ok thing to do in a class
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
Re: Is this an ok thing to do in a class
On Tue, May 18, 2010 at 2:41 PM, Ethan Furman et...@stoneleaf.us wrote: Do you expect afoo.letter[x] to always be afoo.x? Because they aren't: afoo.A = 9 afoo.letter['a'] 1 What you are pointing out is that the assignment is not reversed . But that does make me thing of something I had not. afoo.letter['a'] = 345 afoo.A 1 Thats kinda a bummer, whats a good way to make sure affo.A gets updated? Vincent ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list *Vincent Davis 720-301-3003 * vinc...@vincentdavis.net my blog http://vincentdavis.net | LinkedInhttp://www.linkedin.com/in/vincentdavis -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this an ok thing to do in a class
Vincent Davis wrote: On Tue, May 18, 2010 at 2:41 PM, Ethan Furman et...@stoneleaf.us mailto:et...@stoneleaf.us wrote: Do you expect afoo.letter[x] to always be afoo.x? Because they aren't: afoo.A = 9 afoo.letter['a'] 1 What you are pointing out is that the assignment is not reversed . But that does make me thing of something I had not. afoo.letter['a'] = 345 afoo.A 1 Thats kinda a bummer, whats a good way to make sure affo.A gets updated? It's possible, and not too tough, but... why do you need it done that way? Keeping redundant information seems like extra work with no advantage. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this an ok thing to do in a class
On Tue, May 18, 2010 at 3:15 PM, Ethan Furman et...@stoneleaf.us wrote: Vincent Davis wrote: What you are pointing out is that the assignment is not reversed . But that does make me thing of something I had not. afoo.letter['a'] = 345 afoo.A 1 Thats kinda a bummer, whats a good way to make sure afoo.A gets updated? It's possible, and not too tough, but... why do you need it done that way? Keeping redundant information seems like extra work with no advantage. Not sure I do, basicly I have a long list of values that could be calculated from data. Some may take some time depending on the amount of data. I don't what to calculate them all if not needed but I don't what the user to need to know which are and which are not. But maybe @property is what I need to be looking at, see my other post on the list. Thanks Vincent ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list *Vincent Davis 720-301-3003 * vinc...@vincentdavis.net my blog http://vincentdavis.net | LinkedInhttp://www.linkedin.com/in/vincentdavis -- http://mail.python.org/mailman/listinfo/python-list