Chapter 3. What’s the Right Framework for You?

By this point, you know a little bit about which Python web frameworks are out there, and even have a little in-depth knowledge about some of them. Still, you might be wondering which one is best for you. This is not a question that can be answered here to your satisfaction, because every reader of this guide will have different needs. However, I can offer some general guidelines and answer a couple of frequently asked questions by people new to Python web development.

Don’t Look for Absolute Bests

Recommending one framework over all of the others is not the purpose of this guide, but it’s possible to tell you which frameworks not to look for. New web developers in community forums like reddit usually start looking for one of these, and even if they could find it, it would be the wrong approach to solving their specific problem.

The “Best” Framework

If you search the archives of Python web forums, you’ll find that this question appears every couple of weeks. The thinking goes like this: “Hey, if I’m going to get into web development, I should use the best framework out there.” The problem is that there’s no one right answer to this question.

That’s why this book contains a list of 30 frameworks and reviews for half a dozen of them. The reality is that many frameworks could be considered the “best,” depending on your specific objectives and your preferred way of working. Picking one or two of the frameworks discussed here and trying them out to see if they are a fit for the way you like to code is a much better use of your time than trying to find an undisputed champion.

The “Fastest” Framework

It’s not bad to look for speed in a framework, but making that your main concern can get you off track easily. For example, it can make you worry about deployment before you actually write a line of code. Talk about putting the cart in front of the horse!

The truth is that for many applications, the web framework will seldom be the bottleneck, and even if you really need speed, it’s pointless to have that if the rest of the framework does not conform to your requirements and objectives.

The “Smallest” Framework

When you have lots of programs that do more or less the same thing, like web frameworks, it’s natural to try to classify them in some way. In the Python web world, the terms full-stack framework and micro framework are the most used categories these days. The former refers to a framework with many integrated features, like sessions, authorization, authentication, templating, and database access; the latter usually means a smaller but very focused framework that concentrates on the main things a web application must do, like URL routing.

My advice would be, don’t get too caught up in taxonomies. It’s not necessarily logical that “small” applications require small frameworks and “big” applications require large frameworks. For example, even if you know that you’ll just need a “small” application, you might need several services that micro frameworks do not usually offer, like integrated sessions and form handling. Conversely, you could be writing a “large” application, but more in terms of business logic than web requirements. Instead of worrying about size, focus on the features you need.

Start by Defining Your Goals

If there’s a lesson from the previous section, it’s that to find the right framework for you, it’s better if you have a clear idea of what you are trying to accomplish. Define your problem first, and then look for a framework that seems well-suited for solving that problem and fits the way you think.

Also, once you pick a framework for a project, it’s not as if you are somehow bound by contract to always use that framework. You may very well find that your next project requires a completely different approach, where another framework might bring more to the table.

Desirable Features

While there’s no general checklist for finding the best framework for your use case, there are indeed a few things that you can look for that could simplify your work a lot. It would be wise to at least consider these points while you decide which framework to use.

Documentation

This is probably the single most important thing to look for in a framework. Good documentation lets you get up to speed quickly and start worrying about your application right away rather than trying to find out how to use the framework’s features.

Bonus points if the documentation is well-written, easy to follow, and offers a variety of resources, like tutorials, cookbooks, and videos. People learn in different ways, and some resources, like tutorials, are usually much better for beginners. A discussion of advanced topics can be very useful once you start familiarizing yourself with the framework and trying more ambitious things.

Good documentation also evolves with the framework, so new releases should always cover new features; there are few things as frustrating as having to deal with outdated documentation when trying to pinpoint if a problem is in your code or in the way you are trying to use the framework.

Active Community

It’s a good idea to try to connect with the community of users and developers of your framework of choice. There’s no better way to gauge existing interest in the framework and get a feel for how much development work is under way to make it better. Usually, frameworks will have some mix of mailing lists, IRC channels, and web forums. For most frameworks, these communication channels will also be the official support mechanism, so it pays to find out about them.

An active community is not only a good way of finding out if a framework is “alive” and current, but it can also be a very nice complement to the documentation. Finding out how people have used a feature in real life can be as helpful as the description of the feature itself.

Reliability

The Python language evolves, new ways of working with the Web come around frequently, and the open nature of the Web means constant attention needs to be paid to security considerations. A reliable framework is one that tries to stay current with all of these events. Look for versions that mention compatibility with newer Python releases, take advantage of new libraries and ways of doing things, and offer occasional security fixes or notices.

Extensibility

Once you become proficient in the use of a framework, there usually comes a time when you need to add some functionality or feature that is not already part of it, and in a way that can be easily maintained and understood. If a framework offers well-designed and documented extension points, it will be easier to adapt to your special requirements in a way that doesn’t break with version updates. Also, it will be easier to take advantage of general extensions or plugins that other framework users have created.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset