Sorry, but doesn't this just boil down to the original poster (I think
Javier) writing a sorted-order list which only implemented some of the
desired behaviour? There's nothing wrong with using a try:except: block in
your insert method which logs an error, refuses to accept the item, but
allows processing to continue, if that's what you want. It just sounds like
an example where error-handling policy isn't defined.

In leiu of actual rules about how to handle the exceptions, throwing a
TypeError seems like very acceptable naive behaviour. Even in other
languages, it's possible to end up with exceptions based on type issues in
data structures, Python is not unique in that.

Perhaps I've missed the point, but I feel like it's just the same old "in
the face of ambiguity, resist the temptation to guess" principle.

Javier, perhaps you could post your code to pastebin and we can have a more
specific conversation?

Also, Javier, thanks for the interesting code-related thread to discuss! :)


On Thu, Sep 5, 2013 at 6:19 PM, William ML Leslie <
william.leslie....@gmail.com> wrote:

> On 5 September 2013 17:07, Javier Candeira <jav...@candeira.com> wrote:
> > Just one thing. Comparability is transitive, so I don't have to test
> > comparability of the new element with all existing elements. I only
> > have to check whether it's comparable to the first or root item in the
> > structure. So that test is O(1), not O(n).
>
> Well, you hope that comparability is transitive.  In python 2, *order*
> wasn't even transitive between the provided numeric types: both
> decimal and float would order correctly with respect to int, but not
> with respect to each other.
>
> Maybe there's a bit of a flat spot in python teaching in that people
> don't know how to use NotImplemented correctly.  On the other hand,
> correctly used NotImplemented and __radd__ can't actually solve the
> problem of two numeric types implemented in isolation.
>
> --
> William Leslie
>
> Notice:
> Likely much of this email is, by the nature of copyright, covered
> under copyright law.  You absolutely may reproduce any part of it in
> accordance with the copyright law of the nation you are reading this
> in.  Any attempt to deny you those rights would be illegal without
> prior contractual agreement.
> _______________________________________________
> melbourne-pug mailing list
> melbourne-pug@python.org
> https://mail.python.org/mailman/listinfo/melbourne-pug
>



-- 
--------------------------------------------------
Tennessee Leeuwenburg
http://myownhat.blogspot.com/
"Don't believe everything you think"
_______________________________________________
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug

Reply via email to