How to say $a=$b->{"A"} ||={} in Python?

beginner zyzhu2000 at gmail.com
Fri Aug 17 09:43:00 EDT 2007


On Aug 16, 11:02 pm, "Carsten Haese" <cars... at uniqsys.com> wrote:
> On Fri, 17 Aug 2007 03:15:10 -0000, beginner wrote
>
> > On Aug 16, 9:32 pm, Carsten Haese <cars... at uniqsys.com> wrote:
> > > What is the best solution in Perl need not be the best solution in
> > > Python. In Python you should just use a tuple as your dict key, i.e.
> > > a[k1,k2] = v, unless you have some other constraints you're not telling
> > > us.
>
> > > HTH,
>
> > > --
> > > Carsten Haesehttp://informixdb.sourceforge.net
>
> > I use tuples this way all the time. It is indeed very neat.  But it
> > is not a replacement for double hash-table.  If I want to retrieve
> > information just by K1, it is not efficient to index on (K1, K2).
>
> If you have to look up all values associates with k1 and any k2, you're right,
> that's not efficient. That would fall under "other constraints you're not
> telling us." I'm not a mind reader.
>
> -Carsten

Yeah, I should have mentioned that I actually want to group the data
by K1 and then by K2.




More information about the Python-list mailing list