Syntax across languages

garabik-news-2005-05 at kassiopeia.juls.savba.sk garabik-news-2005-05 at kassiopeia.juls.savba.sk
Sun Oct 23 10:02:06 EDT 2005


Fredrik Lundh <fredrik at pythonware.com> wrote:
> 
>> - comparison returns 4 values (i.e. inferior, equal, superior or not
>> comparable), as in Pliant: "compare"
> 
>>>> cmp("a", "b")
> -1
>>>> cmp("a", "a")
> 0
>>>> cmp("b", "a")
> 1
>>>> cmp("ä", u"ä")
> Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
> UnicodeDecodeError: 'ascii' codec can't decode byte /.../

that is not because of the comparison, but because of the coercion:

>>> 'ä'+u'ä'
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
>>> 

> 
> sure looks like four possible outcomes.


>>> cmp(1, 1+2j)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: cannot compare complex numbers using <, <=, >, >=


a fifth one :-)


-- 
 -----------------------------------------------------------
| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__    garabik @ kassiopeia.juls.savba.sk     |
 -----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!



More information about the Python-list mailing list