Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^4: Perl VS Python

by Anonymous Monk
on Oct 19, 2009 at 01:25 UTC ( [id://801918]=note: print w/replies, xml ) Need Help??


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

So, does Python not have variable interpolation? That would be a deal-breaker.

Replies are listed 'Best First'.
Re^5: Perl VS Python
by Anonymous Monk on Oct 19, 2009 at 02:38 UTC
    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"}});

      Huh?

      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"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-09-10 14:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (1 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.