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

David Mertz mertz at gnosis.cx
Tue Mar 24 01:03:47 CET 2015


For what it's worth, 'cast(x, T)' also reads far more naturally to me.

On Mon, Mar 23, 2015 at 3:08 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:

> 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.
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150323/db6b2828/attachment.html>


More information about the Python-ideas mailing list