Re: Range type adaptation implemented

From: Jacob Kaplan-Moss <jacob(at)jacobian(dot)org>
To: psycopg(at)postgresql(dot)org
Subject: Re: Range type adaptation implemented
Date: 2012-09-24 17:36:27
Message-ID: CAK8PqJFPruSzKXPjsntw5XziWGKp5XtmFSc9J6TVcg_1z3LRBQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Mon, Sep 24, 2012 at 11:44 AM, Daniele Varrazzo
<daniele(dot)varrazzo(at)gmail(dot)com> wrote:
> We could return False to any comparison but still it's not like "you
> cannot do that, mate". Anybody knows an example of unorderable object
> in Python? Is there anything more appropriate than throwing TypeError?

I'd say take a cue from how Python 3 handles trying to compare disparate types:

$ python3
Python 3.2.2 (default, Feb 23 2012, 12:57:05)
[GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.45)] on darwin
>>> {} < []
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: dict() < list()

So I'd say TypeError is correct, perhaps with a message like
"unorderable type: range()" or something.

Jacob

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2012-09-24 17:54:18 Re: Range type adaptation implemented
Previous Message Daniele Varrazzo 2012-09-24 16:44:53 Re: Range type adaptation implemented