Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^5: Perl VS Python

by Anonymous Monk
on Oct 19, 2009 at 02:38 UTC ( #801923=note: print w/ replies, xml ) Need Help??

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

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"}});

Comment on Re^5: Perl VS Python
Select or Download Code
Replies are listed 'Best First'.
Re^6: Perl VS Python
by ruzam (Curate) on Oct 19, 2009 at 23:48 UTC


    In Perl you might write

    printf("Hello %s! Today is %s!", 'John', 'Thursday');

    At least try to make an apples to apples comparison.

      Myopic much? named sprintf compared to named sprintf
      print "Hello $name! Today is $day!\n"

        Just trying to stay in the same fruit category as the original Python example :)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (16)
As of 2015-11-30 19:03 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (778 votes), past polls