No subject

Chris Liechti cliechti at gmx.net
Tue Jul 23 09:30:13 EDT 2002


henk_derudder at hotmail.com wrote in news:3d3d53f4.356458609 at news.skynet.be:

> Hi,

hello. please set a subject in your messages.

> What datatypes can one use as key in a dictionary?

anything immutable. thats numbers, strings, tumples
 
> Can I use for example two longs as key (kind of a double key)?

if you put them in a tuple, sure:

>>> d = {}
>>> d[(1L,2L)] = 1
>>> print d
{(1L, 2L): 1}
>>> d[(1,2)]
1

and as you see, it doesn't even matter if the numbers are longs or ints. if 
they have the same nummeric value there the same in a dict too. 

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list