CodingDisorder
Regular Member
- Jun 21, 2016
- 206
- 237
Hi there.
Over the last couple of years, I had the opportunity to immerse myself in many projects involving Python and learned a lot more than I would've expected.
Here are some tips I wish I had known earlier:
If you ever find yourself having some trouble understanding classes, this video was a godsend for me:
I’d recommend reading Sartre’s thread “Just my little tip on how to learn Python the easy way
” as it provides great resources to learn Python.
Also, there are powerful tools available to write code for you, such as ChatGPT or Copilot, but it’s fundamental to learn how to code properly by yourself before you even think of using them.
Don’t forget to check realpython.com, since their tutorials are generally very easy to understand and quite informative.
That’s it guys.
Over the last couple of years, I had the opportunity to immerse myself in many projects involving Python and learned a lot more than I would've expected.
Here are some tips I wish I had known earlier:
- Don't overuse while loops because it can lead to infinite loops and break your code. Instead, use for loops with break statements to make your code safer and more readable.
- List comprehensions can be really useful, but don't make them too complicated. Stick to the basics and keep it pythonic for better readability.
- Keep your variables simple, and it can save you a lot of headache in the future. Trust me, it's no fun coming back to your project and trying to decipher "while q == g".
- Remember that everything in Python is an object, so you don't need to define a variable to return it from a function. Just return the object directly to make your code more concise.
- Don't reinvent the wheel! Python has tons of built-in functions and libraries that can make your life so much easier. Take advantage of them!
- When it comes to replacing variables in strings, you have a couple of options: format() or fstrings. Don't make things more complicated than they need to be.
- VS Code debugger is your best friend, and it can save you so much time and frustration. Spend some time getting familiar with it and debugging will become a breeze.
- Use docstrings to document your code properly.
- Instead of making a huge mess of a code, try to separate each module/function in a different file. It’s also a good idea to make them modular and include an if name == “main”.
If you ever find yourself having some trouble understanding classes, this video was a godsend for me:
I’d recommend reading Sartre’s thread “Just my little tip on how to learn Python the easy way
Also, there are powerful tools available to write code for you, such as ChatGPT or Copilot, but it’s fundamental to learn how to code properly by yourself before you even think of using them.
Don’t forget to check realpython.com, since their tutorials are generally very easy to understand and quite informative.
That’s it guys.