[Israel.pm] Python talk
offer.kaye at gmail.com
Tue Dec 7 09:59:34 PST 2004
On Tue, 7 Dec 2004 19:06:08 +0200 (EET), Omer Zak wrote:
> The gist of discussion is that Python is, after all, better than Perl x.y
> (for x.y<6.0) when one wishes to use complicated data structures as keys
> of associative arrays.
I beg to differ.
Regarding syntax, I find the Perl way of referencing and dereferencing
clear and easy to use. After all, in Perl there are "only 2 ways to
create a reference; once you have a reference, there are only 2 ways
to use it". That's it - 2 ways to create, 2 ways to use. What's hard
about that? Once you get references, you see that so called "complex"
data structures are really just regular ones that use references as
Regarding the ability to use arrays as keys, Perl does provide such an
ability - both builtin, using an implicit stringification of the
array, or using a module. Apart from the module I already gave, you
have "Tie::RangeHash", "Tie::ListKeyedHash", "Tie::AliasHash" and
possibly others I've missed, all do something similiar, but each with
a particular twist.
In fact, doing a search for the word "hash" on CPAN returns over 7000
Want a hash with checkpoints and rollbacks? Use "Tie::Hash::Transactional".
Want hashes with accessors/mutators? Use "Hash::AsObject".
Want approximative match of hash keys? Use "Tie::Hash::Approx".
Want to use regular expressions as hash keys? Use "Tie::RegexpHash".
I could go on and on...
Still think Python is better than Perl (at least with regards to
hashes)? Does Python have anything like the above modules?
> So this is not just the way my own neurons are wired together.
I think it is :-)
More information about the Perl