Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Mitya Sirenef
On 02/18/2013 10:14 PM, Dave Angel wrote: On 02/18/2013 09:54 PM, Mitya Sirenef wrote: >> On 02/18/2013 09:17 PM, Jon Reyes wrote: >>> Thanks Dave and Mitya for enlightening me about dictionaries. I'm >>> still confused about this though: >> > >> > " so that if two >> > key objects are equal, t

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Dave Angel
On 02/18/2013 09:54 PM, Mitya Sirenef wrote: On 02/18/2013 09:17 PM, Jon Reyes wrote: Thanks Dave and Mitya for enlightening me about dictionaries. I'm still confused about this though: > > " so that if two > key objects are equal, they stay equal, and if they differ, they stay > different

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Mitya Sirenef
On 02/18/2013 09:17 PM, Jon Reyes wrote: Thanks Dave and Mitya for enlightening me about dictionaries. I'm still confused about this though: > > " so that if two > key objects are equal, they stay equal, and if they differ, they stay > different. " > > What does this mean? I won't be comparing

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Jon Reyes
Oh, I see, thanks! I was thinking I'll study 2.7 and once I'm comfortable with Python as a language I'll move to 3. Heck, I don't even know how to create a simple main method. -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Mark Lawrence
On 19/02/2013 01:38, Jon Reyes wrote: Hi Mark. Well, doesn't iteritems() work the same? It's iteritems for Python 2, items for Python 3. -- Cheers. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Jon Reyes
Thanks Dave and Mitya for enlightening me about dictionaries. I'm still confused about this though: " so that if two key objects are equal, they stay equal, and if they differ, they stay different. " What does this mean? I won't be comparing key objects with one another. Also, when I had two

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Dave Angel
On 02/18/2013 08:38 PM, Jon Reyes wrote: Hi Mark. Well, doesn't iteritems() work the same? or am I missing something? By the way I'm sure I read the dictionaries part of Python but I'm unsure if it would take int's as a key for dictionaries. I've been weaned on Java where the keys of hashmaps

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Mitya Sirenef
On 02/18/2013 08:38 PM, Jon Reyes wrote: Hi Mark. Well, doesn't iteritems() work the same? or am I missing something? By the way I'm sure I read the dictionaries part of Python but I'm unsure if it would take int's as a key for dictionaries. I've been weaned on Java where the keys of hashmaps

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Jon Reyes
Hi Mark. Well, doesn't iteritems() work the same? or am I missing something? By the way I'm sure I read the dictionaries part of Python but I'm unsure if it would take int's as a key for dictionaries. I've been weaned on Java where the keys of hashmaps are always Strings. PS: Just checked, wow

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Mark Lawrence
On 19/02/2013 00:52, Jon Reyes wrote: So I have a dictionary and the key is a number. The values are either a single tuple or a tuple of tuples. Is there a better way to go about accessing the values of the dictionary? All the tuples contain four elements. So say: col = {"1": (0,1,2,3): "2": (

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Roy Smith
In article , Jon Reyes wrote: > So I have a dictionary and the key is a number. > [...] > col = {"1": (0,1,2,3): "2": ((0,1,2,3),(2,3,4,5))} The keys here are strings, not numbers. But that's a detail. Somewhat more importantly, that's a syntax error (one of the colons should be a comma).

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Jon Reyes
Sorry if I didn't check the code before I posted it, I just mocked it up in Google's editor. That's what Mitya suggested too, yep, I guess I just need to make it uniform to get rid of the extra checking. Thanks man! -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Jon Reyes
Wow, why didn't I think of that. Thanks! I'll try it now. By the way I think I don't need to wrap the single tuples in runtime because I'm declaring that dictionary anyway beforehand and I could just do it right there. I won't be adding elements to the tuple. -- http://mail.python.org/mailman/l

Re: Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Mitya Sirenef
On 02/18/2013 07:52 PM, Jon Reyes wrote: So I have a dictionary and the key is a number. The values are either a single tuple or a tuple of tuples. Is there a better way to go about accessing the values of the dictionary? All the tuples contain four elements. > > So say: > col = {"1": (0,1,2,3

Dictionaries with tuples or tuples of tuples

2013-02-18 Thread Jon Reyes
So I have a dictionary and the key is a number. The values are either a single tuple or a tuple of tuples. Is there a better way to go about accessing the values of the dictionary? All the tuples contain four elements. So say: col = {"1": (0,1,2,3): "2": ((0,1,2,3),(2,3,4,5))} Then to access th