<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 15, 2013 at 7:44 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 16/08/13 04:10, Eric V. Smith wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I agree with Mark: the proposed median, median.low, etc., doesn't feel<br>
right. Is there any example of doing this in the stdlib?<br>
</blockquote>
<br></div>
The most obvious case is datetime: we have datetime(), and datetime.now(), datetime.today(), and datetime.strftime(). The only API difference between it and median is that datetime is a type and median is not, but that's a difference that makes no difference: both are callables, and being a type is an implementation detail. dict used to be a function that returned a type. Now it is a type. Implementation detail.<br>


<br>
Even builtins do this: dict() and dict.fromkeys(), for example. If you include unbound methods, nearly every type in Python uses the callable(), callable.method() API. I am truly perplexed by the opposition to the median API. It's a trivially small difference to a pattern you find everywhere.</blockquote>

<div><br></div><div>Steven, this is a completely inappropriate comparison. datetime.now(), dict.fromkeys() and others are *factory methods*, also known as alternative constructors. This is a very common idiom in OOP, especially in languages where there is no explicit operator overloading for constructors (and even in those languages, like C++, this idiom is used above some level of complexity). This is totally unlike using a class as a namespace. The latter is unpythonic. If you need a namespace, use a module. If you don't need a namespace, then just use functions. Classes are the wrong tool to express the namespace abstraction in Python.<br>

<br>Eli<br></div><div><br></div><br></div><br></div></div>