Live data from Hacker News

Ask HN: How can I get better at writing production-level Python?

news.ycombinator.com

51–56 of 56 posts

Re: Ask HN: How can I get better at writing production-level Python?

#53
Try new things. Simple over everything is the key to production python code. Too many layers of abstraction is a massive footgun, especially if youre passing objects around a lot, due to dynamic typing etc.

Constantly 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?

#54
post #52
post #30

Search the channel of Arjan from arjancodes.com on Youtube. Watch his videos.

I find his stuff is oriented more to beginners. I'd recommend mCoding instead perhaps.

Will have a look at mCoding. But I think Arjan's videos are on an intermediate level.

Re: Ask HN: How can I get better at writing production-level Python?

#55

Avoid 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…

Avoid writing java... (fixed it for you)

Re: Ask HN: How can I get better at writing production-level Python?

#56

Earlier 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…

Thanks for your reply. Unfortunately, your strategy has not worked for me. The mostly Python people are me continue view types as a burden, not a benefit.
Post reply on HN