[Python-ideas] PEP 484 (Type Hints) -- second draft

Antoine Pitrou solipsis at pitrou.net
Mon Mar 23 23:08:06 CET 2015


On Mon, 23 Mar 2015 14:17:20 -0700
Nathaniel Smith <njs at pobox.com> wrote:

> On Mar 23, 2015 1:03 PM, "Guido van Rossum" <guido at python.org> wrote:
> >
> > On Sun, Mar 22, 2015 at 11:02 PM, David Foster <davidfstr at gmail.com>
> wrote:
> >>
> >> * +1 for the argument order cast(x, T). This is consistent with (x: T)
> elsewhere.
> >
> >
> > I disagree on this. It goes against the argument order of casts in other
> languages, e.g. C, C++, Java, and even in Python -- you write int(x), not
> x(int).
> 
> I don't have any strong opinion here, but I don't find the consistency
> argument convincing. In int(x), 'int' is the verb, and in English verbs
> come before undergoers ("I am inting the x"). In cast(...), though, cast is
> the verb, x remains the undergoer, and int is conceptualized as the
> destination (or something like that), and destinations go in prepositional
> clauses after the object. You'd say "I'm casting the x to int"; (cf "I'm
> throwing the ball to Sarah"). "I'm casting to int the x" is extremely weird.

I agree with cast(x, T). It also nicely mirrors isinstance(x, T).

Regards

Antoine.




More information about the Python-ideas mailing list