[Zope-Perl] Mixing perl arrays with python lists

David Ascher DavidA@ActiveState.com
Tue, 13 Jun 2000 15:25:06 -0700


> The question is: Should perl arrays allow python lists (and tuples) to
> be used as arguments to its functions or should we require the other
> argument(s) to always be another perl array thingy.
>
>    array = perl.get_ref("@")    # gives you a new empty array
>    array[:] = [1,2,3];          # should this be allowed
>
> The python way seems to be to never allow mixing types and to provide
> the functions list() and tuple() to do explicit conversions where you
> want them to be allowed.  I could do something similar and provide a
> perl.array() that turns any sequence object into a new perl array.
> That would make the example above:
>
>    array[:] = perl.array([1,2,3])
>

In fact, the Python way there is a little schizophrenic, since it is in fact
possible to do

	[a,b,c] = (1,2,3)

but not

	[a,b,c][:] = (4,5,6)

I can't say that I have a good answer as to how things 'should' be.

The Python way has been to restrict things, and then in some cases to loosen
up restrictions (witness the fact that the first example above didn't used
to be legal).  I guess I'd go that way (in other words don't allow
cross-type slice-setting and provide a perl.array constructor).

--david