Comparison of strings and integer

Olivier Dagenais olivierS.dagenaisP at canadaA.comM
Tue Jul 25 12:58:44 EDT 2000


I think Python compares the names of the types when you compare two objects
of different types.

--
----------------------------------------------------------------------
Olivier A. Dagenais - Carleton University - Computer Science III


"Franz GEIGER" <fgeiger at datec.at> wrote in message
news:8lkfhs$pav$1 at pollux.ip-plus.net...
> Still not very experienced in programming Python I recently compared
> accidentially a string variable with an integer variable. Python did it
his
> way, which was not my way: I expected a conversion like Perl does or a
> runtime error like REBOL does. Is there any way to prevent Python from
doing
> so?
>
> Python: print "1" > 1 --> 1
>
> Perl: print not ("1" > 1); --> 1
>
> REBOL:  print "1" > 1 -->
> ** Script Error: Expected one of: string! - not: integer!.
> ** Where: print "1" > 1
>
> Many thanks in advance and best regards
> Franz GEIGER
>
>





More information about the Python-list mailing list