Very rough calculations estimate that the number of Python developers in the world is somewhere between 1.8 and 4.3 million.
Figures like these may lead you to think that hiring a Python engineer is easy, and it is — as long as your goal is to hire someone who can casually list Python among twenty five other skills on their resume.
But if you’re looking for a true Python guru who has mastered every nuance of the language, you could be in for a shock.
We’ve collaborated with Pavel Yershov, a Python expert who works for one of our clients, to create this guide packed full of pro interviewing tips, questions, and sample coding tasks that will help you hire an A+ Python developer.
No matter how experienced the Python programmer you’re interviewing is, it never hurts to start with the basics. Check your candidate’s general understanding of programming concepts and common data structures by asking them to explain, for instance, what components a graph has, and what a binary tree is. If you’re happy with their answers, go ahead and ask them about the difference between a depth-first search and a breadth-first search.
Pay attention to the language the candidate uses. You’ll easily be able to tell a bright self-taught computer geek apart from an educated specialist with years of experience under their belt.
Once the candidate has tackled these topics, move on and ask them about the programming paradigms they’re familiar with. Invite them to talk about OOP and how its principles are implemented in Python. Make sure the candidate names all four principles — encapsulation, abstraction, inheritance, and polymorphism. If they can do that, you could pick one principle, say encapsulation, and ask them to talk about its peculiarities in Python, and the syntax of defining a private attribute or method.
While you’re on the subject, ask the Python engineer you’re interviewing how inheritance works in Python, and what abstract class, superclass, and static data are. If your candidate can’t provide a solid answer, they certainly don’t know enough to fill even a junior Python developer position.
Getting into the Weeds
Next, ask your candidate to list Python data types; dict, list, set, and tuple are just a few they should name. Don’t miss the chance to request an explanation of the difference between list and tuple.
A few other areas you might want to cover are Python’s generators and iterators, magic methods, GIL and multithreading, as well as the differences between Python 2 and 3.
One good way to establish whether the Python programmer in front of you is beyond junior level is to ask them what design patterns they know, and which of these are embedded in Python. If they name something simple, like Factory method or Singleton, ask them to explain what it’s all about. However, the one pattern that any good Python developer should definitely be familiar with is the Decorator, so make sure they can explain what it’s good for.
Testing the Framework Knowledge
If the position you’re trying to fill will include working with frameworks, it makes sense to check your candidate’s knowledge of this subject. To start off, simply ask what frameworks the candidate has used before. Nine out of ten Python engineers, even the junior ones, will name Django, so go ahead and test their proficiency with this tool. Here are just a few questions you might want to ask a Django developer:
- What is MVC? How does it work in Django?
- What is your standard approach to working with databases?
- What are the differences between relational and non-relational databases?
- What is normalization and denormalization of the database structure?
- How do you tie a database transaction to the processing of an HTTP request? When would you use it?
- What data types do Django ORM methods return?
- Explain the Django ORM filter() function. What data type does the get() function return? What happens with the result of get() function if the database doesn’t contain the required record?
- What standard Django middleware classes do you know?
- How are HTTP requests and responses processed by middleware?
- What is Celery? What is a worker? What can be used as broker?
Evaluating the Code Quality
You could start by asking the Python developer you’re interviewing to list the main PEP 8 conventions, or alternatively jump straight into viewing their code samples.
Taking a careful look at the candidate’s code is crucial as it accomplishes a number of things. One, it allows you to estimate how well they optimize their code. Two, it shows you whether they stick to PEP 8 and take code quality and readability seriously. Three, the way your candidate names objects and variables serves well to help you estimate the attitudes they have towards other team members who may also have to look at their code at some point, as well as their level of English, which is important if you’re hiring someone from a different country.
Sample Coding Tasks
No interview with a software engineer is complete without a few practical tasks, so invite the Python engineer you’re interviewing to complete some for you. These are a few samples you may want to give a shot:
This task helps determine the candidate’s understanding of data structures in Python.
This one allows you to check the candidate’s understanding of objects and memory in Python.
This task allows you to see how well the candidate understands the peculiarities of mathematical operations in Python.
This one shows whether the candidate knows how to use lambda functions.
This one helps you check the candidate’s understanding of logical operators in Python.
This task enables you to check the candidate’s understanding of how generators work.
The last task helps you test the candidate’s understanding of inheritance in Python.
Bear in mind that the questions and sample tasks above are intended as advice, not a course of action. Not every Python programmer worth their salt will be able to answer all of them, nor does answering all of them guarantee a senior Python developer with outstanding expertise. You’ll definitely want to add a few other questions and consider setting tasks tailored for the project you’re hiring for.
We do hope, however, that you’ll be able to adjust our tips according to your needs and recruitment strategies, and hire just the right type of Python engineer for your business.