The Python language is well-known for being one of the most productive and efficient general-purpose tools available (as we’ve mentioned in our guide to the Pros and Cons of Python Development). Combined with an application framework—a foundation of common code from which you can build your own services—developers are able to deliver ever-increasing amounts of value and resources to users.
By providing a skeleton of code for developers to build on, an effective Python framework should equip developers with the generic functionality and base features an application requires to run. Used well, it should provide an architecture for developers to build an application around and start a project off with best working practices.
Here, we’re looking at some of Python’s most powerful, efficient, and effective web application frameworks. And if you are looking for a Python developer to implement these frameworks, just tell us what you need! We can do the work for you and connect you with up to 5 companies within 72h that match your needs—all for free.
But back to the subject at hand, what should we expect from some of Python’s leading frameworks?
From a developer’s perspective, a Python framework should remove some of the burdens of writing boilerplate code, provide features that will support their development efforts, and save time towards reaching a project goal. It is, in short, a way of ‘not sweating the small stuff’ and diverting focus and attention to the big picture tasks instead.
For a project, a good framework should be more reliable, more robust, and easier to test than a custom solution. Ideally, many headline features should come ready to use, “out of the box”.
In Python development, there are three main classes of framework. These make up the majority of use cases, but they are not entirely independent, unique, or isolated from one another. Each category blends into the other, and a handful of frameworks combine some of the best features of each.
Full-stack Python Framework
As the name suggests, the full-stack framework is an all-in-one solution. These often contain a suite of pre-configured libraries that work well together without extensive additional setup. Full-stack frameworks support developing the entire application from the front-end views to back-end processes such as networking and database access.
A full-stack framework is capable of providing everything a developer needs to deploy an application. They are ideally suited to enterprise-level applications or applications that may be expected to scale to enterprise-level in the future.
Python Microframeworks
In contrast to a full-stack framework, a microframework often takes care of a subset of features and functionality for developers. While not as complete as a full-stack solution, they do allow developers to maintain more freedom around other areas of application development while solving specific challenges.
A primary advantage of micro frameworks is their ability to be combined together, or added as extensions to some full-stack solutions. They allow a freedom and control that could be inhibited by imposing a full-stack solution from day one.
In some cases, a microframework can be extended into a full-stack one as a project scales to meet demand.
Asynchronous Python Frameworks
An asynchronous framework is one designed to handle a large number of connections at once. They are built with scale and performance at the forefront of the design process. Most often, asynchronous frameworks are small, lightweight microframeworks for precisely this reason.
Both full-stack and microframeworks can support some asynchronous functions as part of their design.
Django
A full-stack, high-level, fast, and scalable framework—Django has been the default option for Python web development for several years now. It’s one of the most widely deployed frameworks out there, and it’s been at the forefront of developers' minds for some very good reasons.
Django includes almost everything you might need for web development straight out the box, and it does it well. It allows developers to construct large applications quickly and comes with safe and sensible defaults that make web apps work without in-depth and detailed configuration.
The majority of Django’s drawbacks come from the heavyweight nature of the framework. Including so much out of the box comes with penalties in outright performance. For small and lightweight applications, there may be better-suited solutions.
Django can feature some unusual quirks that may catch out developers. You can not, for example, pass a callable method as a component in a template. Unexpected constraints such as these, despite adding safety to applications, can be jarring if you’re used to other frameworks. Similarly, Django has support for asynchronous views, but not for using async elsewhere in the stack right out the box.
Such constraints, quirks, and limitations of Django can create reasons a developer might look to other solutions for upcoming projects. Moreover, determining a developer’s familiarity with Django and other frameworks is an important question during the interview process, as we touch on in How to Interview a Python Developer and What to Look For.
Use Django when:
- Development speed is a high priority;
- Large base of community support is important; and
- Scalability is a deciding factor.
Web2py
A similarly full-stack framework, Web2py approaches Python web-app development from a different perspective than most. Web2py, amongst its features, provides an unconventional and unique selling point: a built-in development environment and web-based IDE.
While most developers will prefer to download the framework’s source and build the application locally, less technical users may appreciate being able to access the bare metal of the app without prior setup or platform considerations. While no substitute for a complete IDE, it can be a useful tool to have.
Web2py differs from Django in the way it handles data abstraction too. The framework’s constructor functions might take some getting used to, but both frameworks are at least comparable in terms of outright performance.
Some drawbacks of Web2Py include its lack of support for Python’s async functionality. Additionally, there are few options for developers to customise core functions of the framework.
Use Web2py when:
- You want a complete web framework solution out of the box; and
- Future customisation is not a high-priority.
Emmett
The first truly asynchronous framework on our list, Emmet is designed to deliver a full-stack platform for developers while maintaining maximum simplicity at its core. Emmet is the successor to Python framework Weppy, a popular and highly performant Python framework in previous years.
The selling point of Emmett is how few instructions and configurations are required to get a basic, single-route application setup. In this respect, Emmet is more similar to a microframework than a full-stack one.
Emmett includes functionality for data validation, form handling, user validation, and response caching. The ethos of the framework is a ‘just enough’ approach. Each of the framework’s functions are not overly feature-rich but enough to serve their purpose in a production-level app.
Want to know if Emmett is right for you? Just tell us what you need and within 72h we will connect you—for free—with up to 5 companies that you can consult about your Python questions!
Use Emmett when:
- Future extensibility is important;
- Performance is a deciding factor; and
- The finished product is more important than the route to get there.
CherryPy
Describing itself as a “minimalist Python Web Framework”, CherryPy is one of the most mature and developed web frameworks around. First released in 2002, the highly popular framework is now on version 18 and remains highly popular amongst developers.
CherryPy is an object-oriented HTTP framework. It allows for Python’s object model to be dynamically presented as a website or API, making use of some of the languages greatest strength. It’s a way of working that allows developers to build web apps much the same way they would any other object-oriented application.
With a highly modular design to the framework, CherryPy components are easy to manage and can be easily scaled to meet demand. The framework’s maturity lends itself to an extensive base of community support and assistance at all stages of development.
Use CherryPy when:
- Stability and support are high-priority; and
- Working with developers who have used it extensively in the past.
Bottle
A true microframework, Bottle is perhaps the smallest possible practical production framework. Bottle is distributed as just a single file, with no external dependencies outside the Python Standard Library.
Designed to be simple, lightweight, fast, and powerful, it’s a framework that offers a lot to developers on small-scale projects. Despite the lightweight approach, Bottle offers request dispatching with support for URL parameters, templates, a built-in HTTP server, and adapters for third party servers and template engines.
Use Bottle when:
- Rapid prototyping;
- Small personal projects;
- Space is a high priority; and
- Learning about web frameworks and how they are built.
Dash
Dash is a unique framework in that it’s built to do one thing particularly well. Dash exists to create data visualisation interfaces using Python. Combining a Flask web-server, React front-end, and Python development, Dash is designed to create data dashboards and analytical web applications fast.
Built by Plotly, a Canadian company responsible for highly popular and powerful graphing libraries, Dash was officially released in 2017. While its use-cases aren’t as broad or as extensive as others on the list, it is exceptionally good at what it does—data visualisation and graphing in a lightweight solution.
Use Dash when:
- You need to build dashboards quickly; and
- You need data visualisation.
Python Development Frameworks
There’s no such thing as the ‘ideal’ or ‘perfect’ framework for every use case. A framework is just a tool that, like any other, needs to be applied for the role it’s suited to.
Each framework available is dependent on where it’s being deployed, how developers will use it and the developers who will use it. Familiarity, in-depth knowledge, and practical experience count for just as much as benchmarks, features, and functionality.
These are some of the most popular, functional, and productive frameworks covering many use cases with the Python language. There are also many more.
Technical leads and project managers may well have favourites of their own and can, most likely, tailor a solution that works for you. And to learn whether those leads and managers should be freelance or outsourced, read our piece Should You Hire Python Freelancers or an Outsourced Python Team.