[Python-Dev] Cleaning-up the new unittest API

C. Titus Brown ctb at msu.edu
Tue Nov 2 15:05:55 CET 2010


On Tue, Nov 02, 2010 at 05:28:43PM +0900, Stephen J. Turnbull wrote:
> C. Titus Brown writes:
> 
>  > p.s. Seriously?  I can accept that there's a rational minimalist argument
>  > for this "feature",
> 
> It is a feature, even if you aren't gonna need it.  I want it.<wink>
> 
> Many programmers do know that sets are partially ordered by inclusion,
> preordered by size, and (in Python) totally ordered by memory address.
> There's nothing wrong with not knowing that -- these are rather
> abstract mathematical concepts.  But it's very useful that sorted() or
> .sort() use <=, and it's very useful that Python so often obeys simple
> consistent rules, and it would be quite confusing to those who do
> understand that "in Python the set type is partially ordered by
> inclusion" if sorted() used some other relation to order collections
> of sets.
> 
> It's not so hard to change this:

[ ... ]

> If there were an obvious way to compare sets for use in sorting, that
> way would very likely be the most useful definition for <=, too.  But
> there isn't, really (it's pretty obvious that comparing memory
> addresses is implausible, but otherwise, there are lots of candidates
> that are at least sometimes useful).  Do you think otherwise?  If so,
> what do you propose for the OOWTDI of sorting a collection of sets?

I don't have one...

>  > but arguing that it's somehow the responsibility of a programmer to
>  > *expect* this seems kind of whack.
> 
> I don't quite agree that everyone should "expect exactly the
> implemented behavior", but I do think it's a Python *programmer's*
> responsibility to refrain from expecting something else in this case.

...but, as someone who has to figure out how to teach stuff to CSE undergrads
(and biology grads) I hate the statement "...any programmer should
expect this..." because (unless you're going to disqualify a huge swathe of
people from being programmers) it's *just not true*.  I don't expect Python
to cater to the lowest common denominator but we should be mindful of our
audience, too.

I think Python has a great advantage in not being too surprising much of the
time, which helps quite a bit with learning. I hope people keep that in mind
for future features.

cheers,
--t
-- 
C. Titus Brown, ctb at msu.edu


More information about the Python-Dev mailing list