New Python Developers Need These Tools

Matthew Hull
Python in Plain English
4 min readApr 26, 2021

--

Image by Pexels from Pixabay

For any professional programmer, a good workspace and proper organization can be the difference between getting the project completed and spending the next few weeks just working on bugs.

This is Part 5 of my series for beginning Python, so if you are new to Python, why not start at Part 1 and Part 2? They cover the foundations of programming and you get to make cool little programs in the process!

Topics Covered:

  • Installing Python
  • Pycharm
  • Github
  • Logging
  • Virtual Environments
  • Black Code Formatter

Python

As of this writing, Python is at version 3.9 with 4.0 features being revealed. The process for installing it is simple, go here and download the latest version. Installation should be fairly straightforward but know that sometimes you need to put the path to the python/bin in your PATH so you can execute it from the command line. If you’re on a mac and have homebrew, it’s even easier with brew install python. Side note: Python’s package manager is called pip. Getting 3rd party packages is fairly simple with pip: find the package you want, like setuptools, and enter pip install -U setuptools into your terminal. The -U is for upgrading if you already have the package.

PyCharm

There are a few integrated development environments, referred to as IDEs from now on, but I personally use PyCharm.

Pycharm is great in that it’s mostly all-in-one, with a terminal available at the bottom, the ability to execute as well as debug your code, and integrates well with source control such as Github.

There are plenty of others, each having their own benefits and quirks but if you are starting out, use PyCharm. Download it here, install it, then go to preferences -> python interpreter to set your new python installation as the default interpreter for each new project.

All that’s left is to create a new project and start coding! But wait, there’s one thing you might want to do before that.

Side note: note the folder structure. there’s a main.py at root with a tests folder, logs folder, and requirements.txt next to it.

Github

Have you ever dropped a computer, had a hard drive go bad, or otherwise had years of photos and documents lost due to the failure of your machine?

As a programmer, a single 202 KB folder can represent days of work on a particular problem. Losing a personal project is frustrating. Losing a professional project can be devastating. With Github, you can store projects and push changes for free!

Having a Github account is good for two reasons: it allows you to store your projects so you can look back at them and think “wow, I was terrible at programming!”, but it’s also a place where you can showcase your good code for recruiters and interviewers. Whether your plan is to break into this craft for fun or profit, a Github account is a must. Go here and get one now.

I encourage you to create a new project in Github, grab Github Desktop, clone the project to your machine, and learn a little bit about git commands here. Learning how to pull, commit, and push are all you need to know for now, so no need to memorize all of the commands just yet.

Logging

If you have been following along in my beginning Python articles, you’ve seen me use print() a lot to output variables and see results. Now that you have your own workspace, DO NOT USE PRINT(). With your own environment, pip install logzero and use logzero’s logger.

Using a logger allows you adjust the formatting, see which Python file is logging the output, and show the type of the output message.

We’ve been working with informational output, called info messages, but there’s debug, warning, and error messages that can be logged, which you can adjust at runtime to decide which messages you actually want to see.

And logging comes with fun colors!

Virtual Environments

Virtual environments are separate environments which contain a specific python version and only the packages necessary for your project.

This isn’t necessary when starting out but they become critical as you begin programming projects across different machines or start collaborating with others.

The two options right now are virtualenv and pipenv with pipenv being a little newer. If people start asking for your requirements.txt or pipfile, it’s the list of packages necessary for your project’s virtual environment.

Pretty Code

In order to keep my team’s code spick and span, we use the Black code formatter. Black basically reformats the target file to make sure imports are in the right order, code is indented properly, and any strings/lists/functions/etc that are longer than 88 characters are split into two or more lines.

The best part is Black can be integrated into PyCharm and format your files as easily as right clicking and selecting Black. The instructions are in the link above. For a visual representation, this is what the setup for mine looks like:

I think 88 character length is too restricting, so I use a length of 120.

Conclusion

First and foremost, the best workspace is one that gets out of the way and allows you to solve problems the fastest. If something in your workspace creates more problems than it solves, it’s time to find another tool. Do you have a workspace tool you recommend or a favorite logger? Let me know! Till next time!

More content at plainenglish.io

--

--