4 ms·
I would like to know if fellow HNers who regularly code in Python are using f-strings and type hints in your production code or otherwise. I often find myself i
by happy-go-lucky 9y ago
I would like to know if fellow HNers who regularly code in Python are using f-strings and type hints in your production code or otherwise. I often find myself inclined to use type hinting.
- wutbrodo 9y agoI don't think I could've survived engineering in Python without type hints. I came from a big 5 and engineering in C++ for several years and had to run a team of 5 not-so-great engineers in a python codebase. The hit that dynamic typing causes to readability, maintainability, bug risk, etc is _huge_, and type hinting goes some way towards fixing that.
- aisofteng 9y agoBig 5?
- joshuamorton 9y agoHe likely means {Amazon, Apple, Facebook, Google Microsoft}.
- rdslw 9y agoBig5 And "and had to run a team of 5 not-so-great engineers" ? Interesting.
- wutbrodo 9y agoNo, I'm sorry, the way I wrote that was misleading. When I was at the bigco, I was quite happy with the quality of engineers around me. I joined a tiny startup after that and was the lead eng on a Python codebase, and that's where all the headaches of a dynamic codebase with untalented engineers came into play.
- collinmanderson 9y agoI'm still on on Python 3.5, probably will be until Ubuntu 18.04 comes out.
- happy-go-lucky 9y agoThere is support for type hints in Python 3.5. You may want to check this out at: https://docs.python.org/3.5/library/typing.html https://docs.python.org/3.5/library/typing.html
- ambivalence 9y agoNew code at Facebook does use both. Instagram uses both extensively.
- mi_lk 9y agoYou have links to public repos, or you're speaking from work experience?
- ambivalence 9y agoI work at FB.
- frik 9y agoDoes Facebook use Python 3 for Facebook frontend website? Or in PHP/Hack? (Facebook website frontend is well known to be in PHP/Hack)
- ambivalence 9y agoFacebook's WWW is Hack. Instagram's WWW is Django on Python 3.6.
- happy-go-lucky 9y agohttps://en.wikipedia.org/wiki/Hack_(programming_language) https://en.wikipedia.org/wiki/Hack_(programming_language) > Hack allows programmers to use both dynamic typing and static typing. This kind of a type system is called gradual typing... I wasn't aware of such a type system, and there're many languages which use both: https://en.wikipedia.org/wiki/Gradual_typing https://en.wikipedia.org/wiki/Gradual_typing
- collinmanderson 9y agoIt's true. https://thenewstack.io/instagram-makes-smooth-move-python-3/ https://thenewstack.io/instagram-makes-smooth-move-python-3/
- NelsonMinar 9y agof-strings are great. I use Ubuntu 16.04 LTS so I thought I was stuck without easy access to Python 3.6 until I found this PPA. https://launchpad.net/~jonathonf/+archive/ubuntu/python-3.6 https://launchpad.net/~jonathonf/+archive/ubuntu/python-3.6
- Derbasti 9y agoF-strings are super convenient, especially for transient expressions such as debugging statements, but also for things like error messages (I often shy away from them on library code for backwards compatibility, though). I wish they were available as a __future__ import.
- neuland 9y agoI have use type hinting in all my Python code since the beginning of the year. And, I run mypy checking (with --ignore-missing for now) on it too. It's been pretty great with a few exceptions in a couple weird case. And, I've only had to use the `# type: ignore` escape hatch on like less than 10 lines in a thousand roughly. Before type hinting I was getting really down on Python and using a lot of Go. But, since then it's evened out more.
- fermigier 9y agoYes, I'm using F-strings exclusively for new (Py3.6-based) projects, and type hinting quite extensively (also for old projects still based on Python 2.7 - using the '# type: ...' workaround).
- odonnellryan 9y agoYes in every single project! :)
- etimberg 9y agoI've been writing a lot of python 3.6 lately. f-strings are really helpful and I use them all over the place. I haven't used type hints yet.
- jasonrhaas 9y agoLove the f strings but I sometimes don't use them if I'm worried that the code won't necessarily be run in Python 3.6. Unless it's a self contained docker container - I'm wary of using the f strings everywhere just due to compatibility issues. Side note: Languages like Ruby have had this for a long time. Better late than never, Python!