[Israel.pm] Python talk

Mikhael Goikhman migo at homemail.com
Mon Dec 6 13:00:08 PST 2004


On 06 Dec 2004 13:30:19 +0200, Omer Zak wrote:
> 
> My best guess is that it is because Python has a more intuitive way to
> represent nested data structures.  If one wants to represent an array
> (list in Pythonesque) of associative array (dict in Pythonesque) elements
> whose keys are themselves immutable arrays (tuple in Pythonesque) - it is
> very intuitive to represent it in Python.  In Perl one would have to deal
> with references and other yukky stuff which I didn't get around to master.

Do you mean this structure?

    my @friends = (
        {
            name => 'Bob',
            age  => 13,
        },
        {
            name => 'Rami',
            age  => 31,
        },
    );

I am not sure what are your difficulties with it? There are several ways
to work with something like this. 1) Create class Friend, 2) or functions
to manage this structure, 3) access this structure above without syntax
checking (good, since you trust yourself), 4) or with syntax checking (by
creating named constants for the hash keys). 5) There are more solutions.
If you explain your concrete problem, it will be easier to understand
what you mean.

> Informal survey among Perl programmers:
> 1. How frequently do you have the need to represent complicated and nested
>    data structures in your routine software development work?

I need this pretty frequently. Usually 2-3 levels.

> 2. If you do have the need for such data structures, do you go on and bite
>    the bullet or somehow work around it by other means such as blessing
>    objects?

I create a class when it makes sense only, i.e. if it can have at least
several meaningful methods. Otherwise the plain data is stored unblessed.

> I don't think it is a social thing but one of personal preference.

I agree with Gabor here. It is more a cultural thing, if you consider the
fun (or no fun) involved. People from the Perl culture may find Python
too gray and strict to be fun to work with. And the opposite, some may
find Perl too permitting and too-many-ways-to-do-it to be fun for them.

Regards,
Mikhael.

-- 
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'



More information about the Perl mailing list