Python is readable

Kiuhnm kiuhnm03.4t.yahoo.it
Fri Mar 16 08:55:06 EDT 2012


On 3/16/2012 2:53, Steven D'Aprano wrote:
> On Thu, 15 Mar 2012 00:34:47 +0100, Kiuhnm wrote:
>
>> I've just started to read
>>     The Quick Python Book (2nd ed.)
>
> Is this the one?
>
> http://manning.com/ceder/
>
>
>> The author claims that Python code is more readable than Perl code and
>> provides this example:
>>
>> --- Perl ---
>> sub pairwise_sum {
>>       my($arg1, $arg2) = @_;
>>       my(@result) = ();
>>       @list1 = @$arg1;
>>       @list2 = @$arg2;
>
> I don't understand the reason for $arg1 and $arg2. Is there some reason
> why the code couldn't do this instead?
>
>         my(@list1, @list2) = @_;

@_ contains references to arrays. You can't pass two arrays to a function.

Kiuhnm



More information about the Python-list mailing list