learnpython.org - an online interactive Python tutorial

Chris Angelico rosuav at gmail.com
Fri Apr 22 09:08:53 CEST 2011


On Fri, Apr 22, 2011 at 4:38 PM, harrismh777 <harrismh777 at charter.net> wrote:
> My feelings about this are strongly influenced by my experiences with the
> REXX language on IBM's SAA systems--- OS/2 and VM/CMS. In REXX everything is
> a string... everything. If a string just happens to be a REXX number, then
> it can be manipulated as you might expect for a number.

Wow, someone else who knows REXX and OS/2! REXX was the first bignum
language I met, and it was really cool after working in BASIC and
80x86 assembly to suddenly be able to work with arbitrary-precision
numbers!

The "everything is a string, but treat it as a number if you like"
system is rather handy in a few places. I wanted it for my automated
DNS editor - I wanted to concatenate several numbers (from the date,
and the constant "1"), and then, if the resulting number is not
greater than another number (the previous serial), increment. Ahh
well...

I'm not so sure that all strings should autopromote to integer (or
"numeric" generally). However, adding a string and a number _should_
(IMHO) promote the number to string.

print "Hello, "+name+", you have "+credit+" dollars of credit with us."

Okay, that one is probably better done with the % operator, but it
definitely makes logical sense to concatenate numbers and strings as
strings, not to add them as numbers.

Chris Angelico



More information about the Python-list mailing list