Perl is worse!

Steve Lamb grey at despair.rpglink.com
Sat Jul 29 18:15:35 EDT 2000


On Sat, 29 Jul 2000 13:53:02 +0200, Alex Martelli <alex at magenta.com> wrote:
>Yes, so the latter is best when you have a single format you want to
>apply to several different variables at various point, the former is
>best when the names are fixed.  That's why Python supplies both.

    Excellent description except for one thing, I never said that the variable
names were fixed.  Take a look at Perl's ##foo, for example.  Well, more
accurately ${$foo}.  Again, just taking a pseudo-code, not a real lanauge.

>    "Here is a very %(adj)s %(noun)s!"
"Here is a very $$adj:$format $$noun:$format!"
>    "Ecco una %(noun)s molto %(adj)s!"
"Ecci una $$noun:$format molto $$adj:$format!"

>    print format % {'adj':adjective1, 'noun':noun1}
>    print format % {'adj':adjective2, 'noun':noun2}

    print format

    Adj and noun need to be assighed in either case.  Except when we do it
inline we can see what formatting goes with what.  It really is semantical in
nature since there is no different at all in function that I can find.  The
only difference is having to match up what is at the end of the string with
what is right there where you're looking at the moment.

>> "%d:0:0 %c:U %s %s %s %s %d %s %s %s \
>> %d:0:0!",$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k

>>     What variable goes with what again?

>Yes, a format-string with named-placeholders does help with that, too.

    But not as much as just having the variables in line with the formatting
where reading is still the natural left to right (for us natives of European
lanauges) with all information presented where it must be.

>I'm very happy not _having_ to invent some arbitrary name when what
>I want to do is output one or more arbitrary expressions, computed
>on the fly, for example.  Naming has its place, but so does quiet
>anonimity...:-).

    Why do you need to place them at the end?

"1 + 1 = ",1 + 1:0:0, ",really, it is!"

    Again, fake language.  I don't see a need to have placeholders for simple
statements at the end when you can place those statements in line.

>Could be (I _am_, after all, a well-known sadomasochist!), but, if
>it were that, I think I'd be programming in C shell (hard to think
>of a more painful way to make a living; and yet there _were_ people
>writing scripts in it rather than the somewhat-less-painful Bourne
>shell, for reasons I've always found utterly unfathomable...).

    ESC-P comes to mind.  I find all shell scripts horrible.  Any time I need
to work on one I take the basic logic and rewrite in Perl.  Less need to have
to worry about globbing and proper escaping of everything and handing
different input/output expectations from different programs.  Sure, I'll use
grep on the command line but I'd rather see while(<>){m//;} in the script,
thank you.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list