Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Perl VS Python

by runrig (Abbot)
on Oct 16, 2009 at 18:36 UTC ( [id://801618]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl VS Python
in thread Perl VS Python

...with the added bonus that you don't need curly-braces.
I don't see that as a bonus. It gives the "%" key something useful to do in Vi(m?). I don't really see any of your other reasons as disadvantages either (except for macros), but to each his own...

Replies are listed 'Best First'.
Re^3: Perl VS Python
by Anonymous Monk on Oct 18, 2009 at 06:46 UTC
    % is so freaking awesome in python, i'm suprised perl doesnt' use it the same way
    $ perl -e"die q!d %d! % 3" 0 at -e line 1. $ perl -e"die sprintf q!d %d! , 33" d 33 at -e line 1.
      So, "%" would be nice, but "freaking awesome"?? ... I dunno. Between variable interpolation and sprintf (or Interpolation if you really want to get fancy), you get nearly the same functionality in perl, and I don't think I would miss python's "%" much (if I missed it at all, which I don't, because I don't use python).

      And originally, I wasn't even talking about "%" in perl. It's freaking awesome in Vim though :-)

      So, does Python not have variable interpolation? That would be a deal-breaker.
        No, not like perl, it relies on % and dictionaries (hash). Ex
        print "Hello %(name)s! Today is %(day)s!" % ( 'name' : 1, 'day' : 2 );
        In perl that might be you might write
        use Text::Sprintf::Named; my $formatter = Text::Sprintf::Named->new( {fmt => "Hello %(name)s! Today is %(day)s!"} ); $formatter->format({args => {'name' => "John", 'day' => "Thursday"}});

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://801618]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2025-07-17 05:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.