while true: !!!

Alex Martelli aleaxit at yahoo.com
Tue Dec 19 15:04:32 EST 2000


"Rainer Deyke" <root at rainerdeyke.com> wrote in message
news:jJN%5.52075$x6.23325177 at news2.rdc2.tx.home.com...
    [snip]
> > > OTOH Python does not equate characters with integers. C, C++ and Java
> > > do.
> >
> > Wrong!  C's types are always slightly fuzzy, but that does
> > NOT apply to C++ or Java; e.g., in C++:
    [snip]
> 'char' is an integer type, same as 'short' and 'long'.  'int' is just

It can hold some range of integral values, yes, and the
coercion, if needed, is implicit.

> another integer type.  It is possible (and often desirable) to use 'char's
> (or 'unsigned char's) to hold small numeric values.  The same does not
apply
> to single character strings in Python.

The only real difference I can see is that the coercion needs
to be explicit for Python, with ord and chr.

But to say that have implicit coercions is to EQUATE is
_deeply_ wrong; it would be like saying that C++ "equates"
floats with integers, for example.  It most assuredly
doesn't!  Despite the unfortunate fact that the language
standard lets you use a float value where an integral
one is expected, and vice versa.

If you mean 'char is a numeric type' (in C but not Python),
I wouldn't dispute that -- numeric types are NOT 'equated'
to each other, as was originally asserted of characters and
integers, but they _do_ tend to allow freer and more implicit
conversion than other types, in each language (when you
put C++ into the picture, with overloads and template
instantiations, the distinction between them is sharper;
I don't know of any distinction drawn _in C_ between
'integer' and 'non-integer' numeric types, that would make
'integer' somehow a significant C term -- am I just having
a brainstorm...?).


Alex






More information about the Python-list mailing list