Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
We don't bite newbies here... much
 
PerlMonks  

Re: Re: Re: Perl vs. Python: Looking at the Code

by buckaduck (Chaplain)
on Apr 03, 2002 at 14:22 UTC ( [id://156396]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Re: Perl vs. Python: Looking at the Code
in thread Perl vs. Python: Looking at the Code

Another example of ignorance. Perl's "." operator and Pythons .append() list method, are two entirely different things.

A good point (although rudely expressed). (mothra informs me that Python uses foo + bar as the equivalent of the dot operator.) But of course, push is still shorter than .append(). And none of this should have a major impact on which language is preferable.

buckaduck

Replies are listed 'Best First'.
Re: Re: Re: Re: Perl vs. Python: Looking at the Code
by mothra (Hermit) on Apr 03, 2002 at 14:50 UTC
    Yet another point made from not knowing Python at all.

    In Python, "+" can concatenate lists too, which is shorter than push(). In fact, .append() in Python only appends exactly one element to the end of a list, so it's wrong to compare .append() and push().

    My biggest mistake was making the assumption that at least one person reasonably well-versed in both languages would read and respond to this thread.

    My bad. My very bad.

    Also, this subthread is again continuing along the path that seemingly the only point I made was that Python let's you type fewer characters for many extremely common (as in, almost every program and even on most lines of every program you'll write) operations. I'd say the fact that you've ignored the other Python benefits I pointed it is being rude.

      We weren't talking about array concatenation, but if that's what you want to do:
      array = array + list
      I could do the same with Perl:
      @array = (@array, @list);
      But I don't see how that helps your case. Perl's push is shorter than either of these:
      push @array,@list;
      And Python's append() would also be shorter:
      array.append(list)

      But from your previous comment I presume that append() will not accept a list as a parameter. I think I probably want extend() for that last example.

      Of course, the length comparisons vary, depending on your variable names and your willingness to sacrifice legibility. But I don't think that's an argument that anybody wants to make.

      Slightly offtopic: I'm just amazed that Python allows more than one way to do something. I thought that was supposed to be evil or something...

      buckaduck

        You're way off.

        If you really want to try and see which language concatenates in fewer characters, beat this: array += foo

        Shorter than Perl's push(). And, yes the append() list method does accept a list (but appends it as the _last element_ in the list to which you're appending), but you wouldn't know that because you don't know Python, but decided your input was worthy anyway.

        Stop it already.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://156396]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.