r/Python • u/RickSore • Nov 14 '17
Senior Python Programmers, what tricks do you want to impart to us young guns?
Like basic looping, performance improvement, etc.
1.3k
Upvotes
r/Python • u/RickSore • Nov 14 '17
Like basic looping, performance improvement, etc.
5
u/kthepropogation Nov 14 '17
When prompted by a problem that is best solved with something you don't understand, learn it. This includes dunders, itertools, and loads else.
Always be on the lookout for a good library for any task. Be aware that you'll get burned, but you'll also find gems.
I hate most language-native HTTP libraries, but Python is my least favorite I've used. I recommend the
requestsmodule.Learn how generators and iterators work. Use them. Being able to use infinite sequences winds up being useful from time to time and elegant code the rest of the time.
Use a linter. I like pylint, but flake8 is a bit easier and more convenient.
Understand truthiness.
Use SQLAlchemy for databases whenever you're doing anything somewhat complicated.
Use SQLAlchemy-migrate if the database is actively under early development.
3.6 and 2.7 are very different. Keep that in mind if you're working with the one you're less familiar with.
The python standard library is immense. Use it, familiarize yourself with it.
Python is inherently less performant than languages like C++ and Java. If you need the most bang for your clock cycle, look elsewhere.
Despite that, python is excellent for chaining invocations of other software, and acting as a "glue".
Use the best language for the job, not the one you're most familiar with.
Learn other languages too once you're experienced with Python. It'll open your mind to new paradigms and design patterns.