[Python-ideas] Optional static typing -- the crossroads
Sunjay Varma
varma.sunjay at gmail.com
Fri Aug 15 21:25:53 CEST 2014
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/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140815/9c86f82f/attachment-0001.html>
More information about the Python-ideas
mailing list