Perl is worse!
Karl Ulbrich
kulbrich at yahoo.com
Fri Jul 28 15:42:49 EDT 2000
> >a single string, but the % operator has the advantage of being
> >easily tailorable
>
> I never did like the whole placeholder for actual values in print
> statements or other similar constructs. I fail to see why one must do that
> instead of putting what you want there.
There's a "printpl" module by Ka-Ping Yee that lets you use Perl-style
"$variable in a string" substitutions. Even nicer than "string" + var.
I do kind of like Javascript's syntax where anything added to a string
becomes a string, but I'd say that makes more sense in it's intended
setting of web pages.
In Javascript, if a=123 and b="456"...
a+b = "123456" (I disagree, would prefer Type Error)
"foo"+a = "foo123"
""+a+b = "123456" (wish this were required for automagic)
1+"1" is "11", and never 1 or 2 (two ambiguous alternatives).
I wouldn't want text-specific special cases like this in Python
however; if I don't explicitly expect text, or haven't asked for
a conversion to text (via str(), % substitution, or the $printpl
module mentioned), I want to see when something's wrong.
Maybe a rule where a+b is an error, but ""+a+b wasn't (string
literal addition forces remaining items to be strings) would
work for Python, but that sure looks like a Special Case to me.
Karl Ulbrich
More information about the Python-list
mailing list