A classic: https://www.youtube.com/watch?v=wf-BqAjZb8M (Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015)
Ask HN: How can I get better at writing production-level Python?
51–56 of 56 posts
Re: Ask HN: How can I get better at writing production-level Python?
#52Search the channel of Arjan from arjancodes.com on Youtube. Watch his videos.
Re: Ask HN: How can I get better at writing production-level Python?
#53Constantly circle back and refactor. Ruthlessly.
Same as in any lang, focus on data structures and algorithms (business logic is algorithmic) rather than the implementation, at least to start with. Get it working (usually easy in python, it's so dynamic!), make it good, make it fast. A good data model makes coding a joy. If your data structures suck every little thing will accrue friction. This is a red flag that you chose the wrong data model.
Source: 1000s of python hours in engineering and research roles
Re: Ask HN: How can I get better at writing production-level Python?
#54Re: Ask HN: How can I get better at writing production-level Python?
#55Avoid writing java in python. Don't stretch inheritance where where they are not needed - avoid factory classes unless you know for certain that it's called for. Use pythonic stuff like @decorators and enjoy functions as first class objects. Finally, try to avoid using an IDE. This keeps your files and folders structures simple and organized out of necessity . In Java it's almost impossible, but it's very possible in…
Re: Ask HN: How can I get better at writing production-level Python?
#56Earlier quoted context omitted.
About using type annotations in Python: Do you get any push back from your team? I do. "Oh, it clutters the code." I don't know how to reply. And, they continue to write complex code without type annotations. It is hard to reason about. It is a never ending battle with people who come from weaker typed language. They struggle to see the value of stricter types.
Sure, a little bit. It is a change in peoples' workflows after all, and a lot of developers are pretty choosy about that. But I think you can overcome that if you make a respectful case. I think you are spot on that people coming from weakly typed languages often don't realize what they're missing. "It clutters the code" is really just "I'm not used to seeing it that way" so if you can get people to try it out (maybe…