[Python-ideas] Optional static typing -- the crossroads

Haoyi Li haoyi.sg at gmail.com
Fri Aug 15 21:33:20 CEST 2014


> This feature is very new to Python as a whole, why not give it a syntax
that provides a proper separation from what already was?

Mainly because angle brackets are one of C++'s
<http://stackoverflow.com/questions/7304699/c-templates-angle-brackets-problems>
 worst <http://blog.aaronballman.com/2011/05/semantic-whitespace/> mistakes
<http://stackoverflow.com/questions/15785496/c-templates-angle-brackets-pitfall-what-is-the-c11-fix>.
Well, worst among many other equally-worst things, but it's pretty bad. Say
goodbye to your simple LL1 parser!


On Fri, Aug 15, 2014 at 12:25 PM, Sunjay Varma <varma.sunjay at gmail.com>
wrote:

> Another such example, since names are just names:
>
>     dict = {"a": 2}
>     print(dict["a"])  # 2
>
> Overwriting a built in type name is bad, but entirely possible.
>
> dict["a"] here is also confusing with dict[str]. This kind of use could
> also potentially throw off a type linter too.
>
> These probably aren't the best examples out there, but I can definitely
> see this operator's meaning becoming very confused as more people start to
> apply it in different ways.
>
> We should not be just using something because it's there. Especially if it
> causes other problems.
> list[str] may be valid syntax in old Python 3 versions, but it's still not
> going to be correct if used in those versions. You're going to get some
> breakage no matter what.
>
> This feature is very new to Python as a whole, why not give it a syntax
> that provides a proper separation from what already was?
>
> Sunjay
> On Aug 15, 2014 3:14 PM, "Łukasz Langa" <lukasz at langa.pl> wrote:
>
>> On Aug 15, 2014, at 12:06 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
>>
>> On 08/15/2014 11:56 AM, Ryan Hiebert wrote:
>>
>>
>> Getting an item from a class has no meaning for any classes that I’ve
>> ever used, and I haven’t come up with any hypothetical one that would want
>> to do that.
>>
>>
>> --> class Foo(Enum):
>> ...    spam = 'meat flavored'
>> ...    eggs = 'chicken by-product'
>> ...
>> --> Foo
>> <enum 'Foo'>
>>
>> --> Foo['spam']
>> <Foo.spam: 'meat flavored’>
>>
>>
>> I also thought of enums. Looks fairly innocent to me, though. Do you see
>> any cases where the two would conflict?
>>
>> --
>> Best regards,
>> Łukasz Langa
>>
>> WWW: http://lukasz.langa.pl/
>> Twitter: @llanga
>> IRC: ambv on #python-dev
>>
>>
>> _______________________________________________
>> 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/
>>
>
> _______________________________________________
> 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/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140815/cbbbb0e1/attachment-0001.html>


More information about the Python-ideas mailing list