Hacker News new | past | comments | ask | show | jobs | submit login

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.

F-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.

I 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.

I 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.

Big 5?

He likely means {Amazon, Apple, Facebook, Google Microsoft}.

Big5 And "and had to run a team of 5 not-so-great engineers" ?


No, 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.

New code at Facebook does use both. Instagram uses both extensively.

Does Facebook use Python 3 for Facebook frontend website? Or in PHP/Hack? (Facebook website frontend is well known to be in PHP/Hack)

Facebook's WWW is Hack. Instagram's WWW is Django on Python 3.6.


> 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:


You have links to public repos, or you're speaking from work experience?

I work at FB.

Yes, 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).

Love 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!

I'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.

f-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

I'm still on on Python 3.5, probably will be until Ubuntu 18.04 comes out.

There is support for type hints in Python 3.5. You may want to check this out at:


Yes in every single project! :)

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact