Programmers’ time is precious, and just because Python is simple and elegant doesn’t mean you’ll be productive when you program in Python. In order to save time and improve efficiency, there are many things to pay attention to.

Today I’m going to share 10 tips from experienced Python programmers that will help you save a lot of time.

1. Don’t use semicolons

Using semicolons is optional in Python: Unlike other object-oriented languages, you don’t need to use semicolons after every statement.

This seems simple and doesn’t seem to save much time; But once you’ve scaled up to thousands of numbers, these semicolons become distracting and unnecessary to type.

2. Use a handy code editor

Choosing a handy code editor can save a lot of time. Faced with so many code editors, many beginners can feel lost.

Getting used to one editor and then another can be confusing, so choosing one that weighs your hand is a good place to start. Whichever you choose, support Flake8 and PEP8 in real time.

Reference links:

3. Follow the Python code specification

Review images

Following the Python code specification improves the readability of your code, thereby saving you time to review your code.

Reference links:

  • Flask development team Pocoo’s internal coding style guide.
  • Python Development Guide: Best Practices

4. Use help()

Python’s help() is a handy built-in function that can save a lot of time, such as finding explanations for other functions. You can run this function directly from the interpreter terminal. The Python documentation has more on how to use this function.

5. Use third-party libraries

Review images

Python has plenty of third-party libraries so you don’t have to reinvent the wheel every time. For example, you can select a large number of packages available from PyPI (The Python Package Index), a software repository.

Scikit-image is a good example of how image processing tasks such as blur, contrast enhancement, and scaling can be done with just a few function calls.

Reference links:

  • Top 10 Most popular Python libraries of 2015
  • Top 10 Popular Django libraries of 2015

6. Use Cookiecutter

Review images

Cookiecutter is a command line tool that helps you create Python projects from project templates, which can save a lot of time.

7. Strict notes

Review images

Getting into the habit of writing comments can save you and others time, especially for debugging traces.

Comments are critical in teamwork, especially one that has made a lot of changes.

8. Test often

Try to test every component of your program. It may sound time-consuming, but long runs can save you a lot of time, help you find hidden bugs, make you feel more comfortable with your code, and force you to understand how each piece of your code works in the real world.

REPL is a read-eval-print loop, a common code testing tool used by many Python pros.

9. Focus and professionalism

Review images

It is recommended to have an area of focus and expertise. You can do a lot of things with Python, from writing web pages to handling calculations and algorithms.

There are already a number of libraries that can help with these tasks, such as SimpleCV, computer vision processing; Biopython is a biocomputing library; SymPy is a mathematical symmetry.

Diving into areas like these, and mastering a specific framework, helps you learn Python at a deeper level, master a specific code style, and handle a specific type of problem.

10. Code every day

When you get into the habit of writing Python code every day and solving problems in Python, you’ll start thinking in Python, which will ultimately help you solve problems faster, so to speak.

(EarlGrey: but tip 10 is so hard!!)

Original link: SitePoint

End

Please scan the qr code below to follow my official account “programpie”, thank you for your support!