[Python-ideas] PEP 484 (Type Hints) -- second draft
Chris Angelico
rosuav at gmail.com
Tue Mar 24 00:56:46 CET 2015
On Tue, Mar 24, 2015 at 8:05 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 23 March 2015 at 19:55, Guido van Rossum <guido at python.org> 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).
>
> However, in SQL, which is the only language I know of with an with an
> explicitly named cast function (unless you count C++'s
> static_cast<T>(foo) which isn't normal function syntax), the syntax is
> CAST(foo AS type). So there's definitely a precedent (arguably
> stronger, depending on your background) for cast(x, T).
I would *hope* that some stronger argument is used than "SQL puts it
this way". SQL has so many bizarre oddities of both syntax and
semantics that it's seldom a good guideline.
In this case, the isinstance() parallel is a better argument than the
SQL cast, but it's a small point and I could easily be tipped back to
preferring cast(T, x).
ChrisA
More information about the Python-ideas
mailing list