4 ms·
>>> def foo(first, *rest): ... print first ... print rest >>> foo([1,2,3]) [1,2,3] () * sub foo { my ($first,@rest) = @_; print $firs
by gatlin 15y ago
>>> def foo(first, *rest):
... print first
... print rest
>>> foo([1,2,3])
[1,2,3]
()
*
sub foo {
my ($first,@rest) = @_;
print $first . "\n";
print @rest;
}
foo (1,2,3);
1
23
*
It's probably my Python deficiency. My claim that Python's syntax was going to be uglier is probably wrong, but I think the claim that Perl's is appreciably worse is also wrong. We can all get along!
- phaylon 15y agoExactly, it's a trade-off. Making the other side of the fence not impossible to reach, you just have to hop a little. Perl can easily be made nicer and Python can surely with ease be made more flexible.
- TylerE 15y agoNot sure I follow you. Your python example is very explicitly passing a _single_ arguement, a list of three items. If you call it the same way you call the perl code, you'd have the same result.