'1' + 1 ==> True ???
Peter Maas
fpetermaas at netscape.net
Thu Mar 18 03:21:55 EST 2004
Nicola Mingotti schrieb:
> 2) Like C -----> Char is converted to int
> #include<stdio.h>
> int main(){
> printf("%i %i", '1' > 1 , '1' + 1 );
> return 0;
> }
That's not really a conversion. '1' is 0x31 in memory
and 0x31 > 1. C simply compares memory locations, so
comparisons are perhaps even be machine dependent.
Unlike C, Python's comparison results for different types
are defined in a strange but archicture independent way, see
Python Library Reference 2.3.3. The important thing is that
objects of different types are not equal.
> Excuse me again for mistakes or possible (but unwanted)
> rude language .
Sorry, no excuse. :-) Really, please stop excusing, for the
following reasons:
1. It's GREAT that you post in English, as I don't understand Italian.
2. Native speakers also make mistakes.
3. Nobody expects an excuse (I think).
:-)
Mit freundlichen Gruessen,
Peter Maas
--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail peter.maas at mplusr.de
-------------------------------------------------------------------
More information about the Python-list
mailing list