[Python-ideas] Default return values to int and float

Masklinn masklinn at masklinn.net
Mon Oct 3 12:41:12 CEST 2011


-0 on proposal, no big judgement (although it might cause issues:
if `int` and `float` can take a default, why not `dict` or
`Decimal` as well?), but
On 2011-10-03, at 11:57 , Chris Rebert wrote:
> 
> Or would None just be inelegantly special-cased, or…?
Why inelegantly?

    isinstance(default, (cls, types.NoneType))

is pretty elegant and clearly expresses the type constraint,
which is an anonymous sum type[0]. Only issue is that
Sphinx has no support for sum types for the moment.

[0] http://en.wikipedia.org/wiki/Sum_type


More information about the Python-ideas mailing list