Common Python Interview Questions you’ll most likely be asked
For the last few weeks I have been interviewing several people for Python developer position and to my surprise found out that all of them had no idea about Python virtual environments. Answering this common Python interview question may not get the job, but at least you would continue the interview process.A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project A depends on version Django 1.8 but, Project B needs Django 1.9.6” dilemma, and keeps your global site-packages directory clean and manageable.$ pip install virtualenv
My disappointment is compounded when a candidate misses this topic even when they claim several years of Python experience. Isolation and repeatable clean environment development without hidden dependencies on the base system is a good thing. Virtual Environment primary goal is to conveniently provide Python level isolation. For Python packages that depend on system libraries, only the Python level part of those packages are isolated. Provided the
developer is fully conscious that this is python-level-only isolation, then it is useful.
I can sense some developers bristle at the mention of virtual environment. What about using Docker instead of virtual environment? You can install all dependencies inside a container instead of virtualenv. Installing dependencies in Docker has it’s advantages over using just virtual environment, because thanks to containers, the developer doesn’t have to worry about system’s dependencies, and your app is now better isolated. However running Python becomes a bit cumbersome, because developer doesn’t have dependencies installed on machine, and developer would have to get into docker container to run Python there. Just use Python as you always do