Microsoft's Python engineering team posts about Python support in Visual Studio and VS Code, the language server and Python library trends.
HN commenters cite it as evidence of an active Python group at Microsoft focused on Visual Studio and Azure, and link its post on idiomatic EAFP versus LBYL.
> If your code is unintentionally executing sqrt(-1) (or unintentionally indexing out of bounds, etc) then something is wrong with your program.
This is not Python's design. You might dislike Python's design, sure (many people do!), but it is recommended Python practice to try to do something, catch the well-defined exception, and implement the fallback rather than to check in advance.
https://docs.python.org/3.5/glossary.html#term-eafp
https://blogs.msdn.microsoft.com/pythonengineering/2016/06/29/idiomatic-python-eafp-versus-lbyl/
> Catching ValueError/IndexError in those cases is futile, how can one trust a buggy program to handle itself?
The program is not buggy.
(Also, it's absolutely possible to design software where bugs are contained to part of the code: for instance, if you hit a bug in your Python code while handling a web request, you should return a 500 to that user and carry on instead of aborting the whole web server. In fact, it is precisely the relative lack of undefined behavior in Python that makes this a good approach: if you were doing this in C, a wild pointer could well corrupt some other server thread!)
You can offload both 1 and 2 to third party services - one of the major ones with a properly public API that officially supports (and thus charges for high volume use) use by other parties is Microsoft's Project Oxford [0].
You could also use some of the Google APIs, but those are more-or-less unsupported, and subject to change as Google needs to change them.
From there, it's a matter of transforming intent into action.
It's entirely possible to do, but you'll have a lot of learning to do to implement it. One place you might start looking is at the Microsoft Python blog [1].
[0] https://www.microsoft.com/cognitive-services/
[1] https://blogs.msdn.microsoft.com/pythonengineering/2016/02/15/talking-with-python-fabrikam-pizza-shack/
There was an announcement a few weeks back about their Python JIT VM that they're developing, which is currently only for Windows but they say they're planning for other operating systems as well: https://blogs.msdn.microsoft.com/pythonengineering/2016/02/12/welcome/
And also a few months ago they posted to the Django developers mailing list about developing MSSQL as a first-class database for Django: https://groups.google.com/forum/#!topic/django-developers/FbBcUCzrSZo
It seems pushing MSSQL for Linux is the next step.
Meanwhile, I hope they can get things running ported to FreeBSD, since that's what I use for the server.
As pointed, you can use either a default dict or just simply, and [more pythonic](https://blogs.msdn.microsoft.com/pythonengineering/2016/06/29/idiomatic-python-eafp-versus-lbyl/):
try:
bar[baz] += 1
except KeyError:
bar[baz] = 1
Also you can check if a key is in a dict simply by doing "if baz in bar" no need for "list(bar.keys())", which will be slow (temp object + linear scan) vs O(1) hashmap lookup.
This is why Python 2 isn't optional yet:
http://py3readiness.org/
Of the top 360 libraries, only 332 of them support Python 3 (but almost all of them still support Python 2).
This analysis was done in March and expected even support for Python 3 and 2 around now:
https://blogs.msdn.microsoft.com/pythonengineering/2016/03/08/python-3-is-winning/
So maybe next year it will be optional, but not yet.
Isn't that change coming now?
Most of the most popular libraries have python 3 support now, fedora will soon move to python 3 as default, and there are soon more developer support behind 3 than 2.[0]
[0] https://blogs.msdn.microsoft.com/pythonengineering/2016/03/08/python-3-is-winning/