Python to Perl Conversions
Florian Weimer
fw at s.netic.de
Fri Aug 20 06:29:43 EDT 1999
wtanksle at dolphin.openprojects.net (William Tanksley) writes:
>
> > Note that Python doesn't support hash
> > slices, which in Perl are simple:
> > @hash{k1,k2,k3} = (v1, v2, v3)
>
> That's a good point, although I'm not sure what Python can do about it --
> our slice semantics talk about gaps, and hashes don't have gaps. I
> suspect we'd have to call it something other than slicing (this seems
> pretty reasonable).
You can use `hash.update({k1: v1, k2: v2, k3: v3})', which has the
additional benefit of putting keys and values closely together.
More information about the Python-list
mailing list