low*_*rin 11 python static-typing typing python-3.6
因为静态类型在python 3.6中可用.
是否可以强制python项目或python文件集的静态类型?
我认为你不能强迫,static typing
但你可以使用检查器mypy
.
根据The Zen of Python, by TimPeters
你的第2行,Explicit is better than implicit.
静态打字是一件好事,但Simple is better than complex.
......
$ python3.6
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Run Code Online (Sandbox Code Playgroud)
您可以annotations
在Python3 中使用,这可能会帮助您获得静态类型的一些好处.
但是,如果要在Python中完全实施静态类型,那么它将不再是Python.它是一种鸭式的动态语言,因此会失去所有的动力.如果你真的打算使用静态类型的语言,最好不要使用Python.
归档时间: |
|
查看次数: |
5933 次 |
最近记录: |