[Python-3000] optional argument annotations

Andrew Koenig ark-mlist at att.net
Fri Nov 24 20:42:31 CET 2006


> Hm, I think it would be fine if there *was* no distinction. IOW if
>
>   def foo(a: None) -> None: pass
>
> was indistinguishable from
>
>   def foo(a): pass
>
> In fact I think I'd prefer it that way. Having an explicit way to say
> "no type here, move along" sounds fine.

I'd like to urge against making None magical -- I don't see any reason for
it.

Instead, consider that if I say

	def foo(a: T1) -> T2:

I am presumably going to accept an argument of type T1 or a type derived
from T1, and return a result of type T2 or a type derived from T2.  In which
case,

	def foo(a): pass

should be equivalent to

	def foo(a: object) -> object: pass

and we don't need to recycle None for the purpose -- especially as
ininstance(None,object) yields True and I presume that isn't going to
change.




More information about the Python-3000 mailing list