Alright, Roberts Greibers here with another experience-based Python post.

I’ve been working professionally as a Python developer for more than 5 years and now I’m also helping people who are at the start of their careers (or in a similar position I was in) to become Python developers. 

I used to be a quality assurance engineer – manually tested website projects and mobile apps. (iOS, Android)

So I totally get how it is when you want to move away from your current role and get into a more profitable position, for example, become a Python/Django developer.  

What I’m about to show you in this post are five of the most important tools I used and my clients are using now (see a cut from a LIVE Zoom video call below) that made me look like a senior Python developer even though I was just starting to learn Python.

Lots of people see the comfortable lifestyle and money that comes along with a Python developer job but they just want to stand on the sidelines and live vicariously through me or through others by watching python youtube tutorial videos, IT-related movies, etc.

And they never take any actionable steps to become a Python developer.

If you want to become a real professional Python developer then this post is for you.

But remember, you have to read very carefully and pay attention to what I’m about share with you because I’ll show you the actual tools used by professional Python developers!

I’m really surprised to see how many misleading “tutorials” are out there, presenting their tips as something valuable when in reality the stuff they show is never used in a real-world project.

If you like the idea of becoming a real professional Python developer and learning about tools used in a real project then pay attention now!

Use Python built-in tools for debbuging

Tool number one, or you could say it’s a combination of tools you can use to debug your code.

If you’ve never worked in a professional environment as a Python developer you’re probably not even aware of the fact that there are built-in Python tools you can use to debug your code. 

What do I mean by “debug your code”? Well, when you work on something that’s longer than 5 lines of code you’ll eventually run into a situation where something seems to be not working in the middle of your script. (Your own mistakes – bugs)

Usually, as a beginner, you run your Python script over and over again while changing a line here and there until you fix the problem, right?

Run Python file in PyCharm

Well, but that’s the dumb way to debug your code.

What if your Python script grows into 1000+ lines of code that executes over a longer period of time, will you still be running it each time and waiting for it to finish?

– Probably not. 

It’s NOT really your fault if you’ve never seen a different way. It took me years to find mentors who showed me the right combination of Python tools I can use to debug code and fix bugs quickly.

And I’m about to share the first tool here with you.

Take a look at the screenshot below and read STEPS 1, 2, 3 from the screenshot.

Using Python tools - breakpoint()
Using Python tools – breakpoint()

When you run your Python script with breakpoint() in the middle of the script, it will stop and give you an option to check what kind of variables and values you have available.

See the screenshot below where I’m checking the value of item variable in the first iteration of for loop.

Using Python console to debug "item" variable
Using Python console to debug “item” variable

At this point – in Python console, I’d use dir(), print(), type() to determine if something is wrong with the data that I’m seeing or if I actually made a mistake.

I can tell you from my own experience, you’ll end up wasting years trying to figure out things on your own – looking for the right tools to use if you won’t have someone with already gathered experience to mentor you and show you the right way. 

Actually, these tools are the ones other Python developers told me about. When you’re just starting out you’re not even aware of the tools that exist and you end up wasting a lot of useful time. 

And this is just a small portion of what I’ve shared with my client from the video above that helped her to find & fix problems way faster than most people.

Obviously, feedback and code reviews also is a big part of learning Python.

Get mentors (someone to help you)

This leads me to tool number two, well maybe you can’t call mentors a tool, but if you think about it – anything that somehow helps you move forward is a tool, a method, a way to get to the next level.

I’d never mention mentors here if that would not have been the most important part of my career. 

Believe me or not, I am the person who used to have a big ego attachment to saying: “I figured out this by myself, no one helped me.” I also wasted a lot of time doing so. 

I wish I’d realized earlier in my career that having someone who can give you feedback, code reviews, and tell where you’re making mistakes is the most important tool you can have as a beginner Python developer. 

Here’s a screenshot from a conversation with a client from the previously mentioned video – struggling to find the root cause of the problem. 

Having a quick Zoom call to solve a problem
Having a quick Zoom call to solve a problem

You can already see me suggesting breakpoint() tool – it’s what I suggest and use myself all the time. 

But eventually, I saw this was a bit of a strange problem and suggested a quick Zoom call, we found a root cause and fixed it in like 5 minutes

Get code reviews

Not only access to someone over Whatsapp, but code reviews is something that helps a lot, take a look at the screenshot below where I give in-depth code feedback to one of my clients.

Giving code review to a mentoring client
Giving code review to a mentoring client

Your current environment

I’m sure you’ve heard this saying before, but you’re the average of the five people you hang out with the most.

So you’ve gotta ask yourself…

Who are the people you’re spending time with? 

Can they help you get a job as a Python developer?

I remember my old environment was full of people working on quality assurance related projects I remember my old environment (back in my quality assurance testing days), attending quality assurance conferences.

Yeah, we did work on automation projects here and there, but automation is nowhere near building an actual development project with Python. 

Long time ago from THEORY AND PRACTICE OF SOFTWARE TESTING conference website
THEORY AND PRACTICE OF SOFTWARE TESTING conference back in 2017

Most of them thought they already have a job for a while and it’s too hard or risky to switch to a development position now, already a couple of years in. 

Don’t get me wrong. You don’t have to completely cut ties with your current co-workers, friends or family, but just realize that they shape your reality more than it might be good for you.

And a lot of times in QA you’re forced (usually by your managers) to switch between a bunch of different technologies all the time.

Slowly becoming a jack of all trades but master of none while actually, you should be focusing only on one tech stack so you can become an expert in it.

Avoid coding bootcamps

Also realize, who’s going to help you, a coding bootcamp?

If you never managed to get PASS Python fundamentals it’s NOT your FAULT!

You might be stuck in the process of becoming a Python developer because every other teaching system on earth that I’m aware of is based on a strict time period. (1 week, 10 weeks, etc.)

Where if you don’t learn such and such technology in a certain time period  – YOU FAILED! 

If you’ve ever attended a coding bootcamp, how many of the students got a job after it? My guess is not a lot.

I’m saying this with an exception of a few coding bootcamps – you might be able to find a good one if you look hard enough.

Teaching in Riga Coding School
Teaching in Riga Coding School

As you can see from the picture above I did teach a part of a local coding bootcamp here in Riga, Latvia. It was the first and the last time I taught coding under a different company. 

The system in most coding bootcamps is not designed to help students, rather make money. I never wanted to be a part of an organization that I know won’t really help people, so I left after the first time. 

Don’t take this the wrong way, I did my best and students were thankful for the things I taught them.

But not even the best students were job-ready after only 2 weeks of intensive learning, it’s just not possible in the IT field. You need to work on your skills over a longer period of time with constant feedback, code reviews.

Even though most coding bootcamps promise job offers after graduation. (good for marketing)

Find people with experience

So what you need to do is you need to start hanging out with people who are where you want to be. And the good thing is, the internet has made that easier than ever right? 

Hang out with people who are already where you want to be – working in the IT industry as Python developers.

And yes, pay them. Because when you pay – you pay attention. Investing in mentors is money that is an investment in yourself and your future. 

And most of the time this money comes back multiplied. 

Go look up an average salary for a Python/Django developer in your local area.

It’s probably already twice as you’re making at the moment. So, why would you waste any time?

I’ve literally mentors for almost every single area that is important for my life.

Plus when you become a developer you get mentored by more experienced developers automatically just because they will review your code after every feature you develop. 

See the screenshot below for a code review I did for one of my colleagues while working on Revolut payments integration.

Reviewing Revolut integration code
Reviewing Revolut integration code

You have no access to such luxury when you’re just starting out, that’s why most people are stuck in the lowest of lowest levels – they never invest in themselves to move on to the next level.

“Oh, Roberts is just saying that so people join his mentoring.”

Look, I don’t need you to become my client. I’m good.

For me, it literally doesn’t make a difference at this point. 

I’m already in a position where I always wanted to be.

Just so you know. 

But realize that if you don’t get mentors, you’ll be stuck constantly trying to figure things out. 

Without mentors you’ll always have to try new things, never knowing if they’re going to work, you’ll doubt yourself way more than is good for you and you’ll waste tons of precious time. 

Auto format code

Tool number three. This one sometimes surprises me. There are so many tools out there that can instantly make you appear like an experienced developer, but people keep using a notepad to write code, lol.

If you’re serious about becoming a Python developer, download PyCharm and start to use it whenever you develop a Python project.

Here’s a recent post I did about amazon.com automation with Selenium where you can practice using PyCharm.

PyCharm is the best editor available for Python. It includes most features and code suggestions for Python available.

It’s very easy to write and debug code with PyCharm.

There are a lot of tools I’m sharing with my clients in the mentoring process, but here I’ll show you the one that helped me the most.

I’m talking about using keyboard shortcuts to format your code and autoformat on save plugin.

Use “Reformat Code”

First, realize it’s possible to just manually format the code you have selected or format the whole file you have opened at the moment.

The feature is available in PyCharm under

  • Code -> Reformat Code (will format just selected code in .py file)
  • Code -> Reformat File (will format the whole .py file)
  • Code -> Optimize Imports (will change the order if imports in .py file, remove unused ones)
Using "Reformat Code" option in PyCharm
Using “Reformat Code” option in PyCharm

All of the above options can be configured with keyboard shortcuts (you can already see from the screenshot above – on the right side of each option there’s a keyboard shortcut next to it.)

You can use the default keyboard shortcuts or if they’re not comfortable for you, you can configure code autoformat features to use your custom keyboard combinations.

You have to figure out what’s comfortable for you.

Configure custom keyboard combinations

I’ve already configured my keyboard shortcuts to use custom combinations, for example, I’ve found the best combination to autoformat tool for the whole file for me is: option+shift+L

If you also want to configure custom keyboard shortcut combinations, first open up PyCharm’s Preferences. (see the screenshot below)

Change keyboard shortcut for "Reformat Code" option
Change keyboard shortcut for “Reformat Code” option

Once you have PyCharm’s Preferences window opened, look for Keymap on the left side menu.

Keymap is where all keyboard shortcut combinations are configured for Python development environment tools.

In the Keymap section – on the right top side you have the option to search for available tools.

Use the search box to search for the keyword “Reformat” and you’ll be able to find all the tools related to Python code formatting.

You can configure a specific keyboard combination for each tool if you double-click on it.

Why you should use a plugin

As a beginner, you will even forget to use the keyboard shortcut combinations mentioned in the previous steps.

I know this from my own experience, I used to forget everything, I’m the person who needs to do a thing 50 times to remember it.

So the best approach I’d suggest you do is just install the Save Actions plugin in Pycharm. (see the screenshot below)

Install "Save Actions" plugin in PyCharm
Install “Save Actions” plugin in PyCharm

It’s a plugin that lets you trigger an autoformat tool in PyCharm every time you save your .py file.

This essentially means you will autoformat your code every time you’re going to save it. It really is a productivity “hack” to have way better-looking code.

You can quickly type code and don’t really worry about the format of it because it’s all done automatically.

Once you’ll install the Save Actions plugin and restart PyCharm you’ll be able to see “Save Actions” configuration section on the left side menu in PyCharm’s preferences.

Configure "Save Actions" plugin in PyCharm
Configure “Save Actions” plugin in PyCharm

In order for Save Actions plugin to auto-format your code on .py file save – you need to check the following checkboxes in the configuration section:

  • Activate save actions on save (before saving each file, performs the configured actions below)
  • Optimize imports
  • Reformat only changed code (only if VCS configured)

Save & Apply and go test it in a new Python file.

Use Django shell plus

If you’re already working on your own projects (as you should be) – you might be familiar with a Django environment.

I remember when I first started I had a hard time understanding how a database is connected to the whole project and how I can “try things” with the database objects.

Django shell plus is a console tool to help you create, read, update and delete database objects in your project.

Django shell_plus
Django shell_plus

How to install Django shell plus

Django by default comes along with a shell, but there’s a package out there that includes shell_plus – essentially shell_plus is way better and easier to use.

It auto loads all your models into the shell while in the meantime with a default shell you’d have to import all models every time you open up a shell to work with them.

To install shell_plus, you need to install django-extensions package:

pipenv install django-extensions

Once you install django-extensions package, find settings.py file in your Django project and inside settings.py file find INSTALLED_APPS list.

Django settings with "django_extensions"
Django settings with “django_extensions”

How to use Django shell plus

After you set up configuration from previous steps you’re all set.

Now you can open up shell_plus with the following command:

python manage.py shell_plus

You can see from all the green colored lines – all of them are imports that you’d have to do manually inside the default Django shell.

Django extensions shell_plus do that for you.

Access database objects easily in shell_plus
Access database objects easily in shell_plus

Use playground environment

Finally, we come to tool number five and I’d say it’s one of the few tools that really changed how productive my work is today.

Whenever you work on something larger than 100 lines of code, you’ll end up in a situation where you’ll have to tweak a certain part of your code until it’s perfect.

Usually, the script or project you’re working on has a certain environment, for example, in Django, you have your project environment with access to Django models (your database objects).

Create your own “trash” project

When you start to tweak a certain part of code it becomes very difficult to re-run it all the time, it gets frustrating to work on that part of code.

Whenever that happens what I do is I create a new Python project with a new Python file outside of the real project I’m working on.

In my “trash” project I don’t pay attention to qualityPLEASE don’t take this as a good code quality example – this is purely to quickly try things and move them back to the real project.

After coming up with a certain part of code I’d move it to the real project and that’s where I would actually format the code properly.

Trash project to try quick code solutions
Trash project to try quick code solutions

The above works for simple Python projects, but won’t work for a Django project, you’d have to create a new Django project which is total overkill just to tweak a small part of the code.

What else can you do?

Using Django custom command

When it comes to the same approach in a Django project, I’d suggest you create a custom Django command called run_playground.

This can be a file where you can run your Python code within the Django project environment.

Documentation for Django custom commands can be found here.

Django custom command docs
Django custom command docs

Create run_playground.py

Before you can create a run_playground command, you need to have a Django project already set up.

Just for the sake of an example, I’m going to take a mentoring project I usually use to give examples to clients.

In your project you also want to have a Django app already created, for me it’s an app called api.

Just to be clear, you can create a custom management command in any Django app, it does not have to be called api.

Inside your Django app folder:

  • Create a new python package called: management
  • Inside management package create python package: commands
  • Inside commands package create a .py file called: run_playground.py

See the screenshot below:

Creating run_playground.py file
Creating run_playground.py file

Set run_playground.py content

And the content of the file should be kept very simple. At least, in the beginning, this is what you want to have as the base.

Now every time you’ll need a Django project’s environment to tweak code you’re working on you’ll be able to place your code inside handle method.

To run playground see explanation below.

from django.core.management import base


class Command(base.BaseCommand):

    def handle(self, *args, **options):
        print('this is run_playgorund.py')

Once you’ll have run_playground.py content set, all you need to run it is execute the following command:

python manage.py run_playground

Expected output:

(mentoring) robertsgreibers@MacBook-Pro mentoring % python manage.py run_playground
this is run_playgorund.py
(mentoring) robertsgreibers@MacBook-Pro mentoring % 

Summary

And that brings me to the summary, where you have to realize – really, really pay attention NOW! 

Even if I’d give you here all the powerful tools and techniques I’ve learned over the years of working as a Python developer it will be really hard for you to succeed alone.

Don’t waste your time!

Do you want to know why the majority of people fail with their plan of becoming Python developers? Because they wait! They doubt, they procrastinate!

And they tell themselves:

“Oh, it’s not the perfect time to start yet.”

I gotta wait till I have more free time.”

Let me tell you something wonderful – there’s never a perfect time!

There’s never a perfect time!

You want to have a sense of urgency! You want to be impatient!

Because if you don’t – you’ll look yourself in the mirror one day wondering – what if?

What if I had started one year ago? Where would I be today? What if I had started working on my skills? How many epic opportunities would I have today? 

Take advantage of your opportunities!

You need to grasp opportunities when they present themselves to you. 

Look at people like Steve Jobs for example. 

He was known to be quite impatient with things he wants to get things done right away even if they weren’t perfect. 

Go and start working on your goals! Improve along the way and don’t procrastinate until the time is right!

That’s why you now have the opportunity to reach out to me. This is your golden opportunity! Take advantage of this opportunity before others are taking it away from you.

I’ve left details about how you can reach out to me down below, talk to you soon!

I'll help you become a Python developer!

If you're interested in learning Python and getting a job as a Python developer, send me an email to roberts.greibers@gmail.com and I'll see if I can help you.

Roberts Greibers

Roberts Greibers

I help engineers to become backend Python/Django developers so they can increase their income