Re: Range type adaptation implemented

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Jacob Kaplan-Moss <jacob(at)jacobian(dot)org>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: Range type adaptation implemented
Date: 2012-09-24 17:54:18
Message-ID: CA+mi_8aj57OP2BAtFi7210wN8FnQOGtXDVjVTDSKxj7QQiaYtQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Mon, Sep 24, 2012 at 6:36 PM, Jacob Kaplan-Moss <jacob(at)jacobian(dot)org> wrote:
> 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.

Good, with an hint about using postgres operators I think it would fit the bill.

Thank you.

-- Daniele

In response to

Browse psycopg by date

  From Date Subject
Next Message Tobias Oberstein 2012-09-26 16:56:33 Session state per transaction
Previous Message Jacob Kaplan-Moss 2012-09-24 17:36:27 Re: Range type adaptation implemented