python vs ecmascript
Steven D. Majewski
sdm7g at Virginia.EDU
Fri Nov 16 23:27:23 CET 2001
On Fri, 16 Nov 2001, Peoter Veliki wrote:
> > > also a bit annoyed at some things like having to wrap objects in a str()
> > > before
> > > printing, I don't see why this can't be automatic.
> > Since when? The print statement automatically invokes str() on its
> > From the documentation:
> I'm using Python 2.0 at the moment (it is necessary as it is integrated
> into another product), perhaps this limitation was removed in later
> versions. If I try to do this:
> print "integer i = " + i
> it will barf on this and tell me that i is not a string, I must do this:
> print "integer i = " + str(i)
You don't need the 'str' -- you can do:
print "integer i =", i
print doesn't require the 'str' : '+' does!
string concatenation and integer addition don't mix, and it's not
exactly clear what an expression like: "6" + 2
ought to yield: "62" or 62 or 8 or "8" ?
Labeling ambiguous statements as an error makes for stronger
typing than auto-magic conversions.
[ I still think it was a mistake to use the same token for both
addition and concatenation, but it's too late to fix that glitch! ]
-- Steve Majewski
More information about the Python-list