Python is a widely used, general-purpose, high-level back-end programming language that’s highly valued by startups who need to quickly prototype and develop applications, as well as data-driven companies that need to integrate data analysis and statistical techniques into their workflows.
Its combination of readability, flexibility, and suitability to data science operations have made Python one of the most popular and beloved languages according to developers on Stack Overflow. In this article, we’ll explore what sets Python apart from other programming languages, why it’s popular with data scientists, and what you should look for in a Python engineer.
High-level, readable, and efficient
One of Python’s defining characteristics is its efficiency. Every programming language has to balance the programmer’s time and the machine’s resources. Python is biased toward the former, with a guiding philosophy that comes down to “there should be one—and preferably only one—obvious way to do something.” That can mean there’s a bit of a learning curve as developers learn the ins and outs of Python syntax, but the upside is that developers can do more with fewer lines of code compared to more lower-level implementation languages like Java or C++. This efficiency is especially valuable for startups who need to quickly prototype applications and get them to market.
Python is also famous for its code readability沙巴体育足球开户, meaning that an application written by a developer in Python is more likely to be intelligible to the developers who have to maintain it months and years down the line.
Beloved by data scientists
Along with R and Java, Python is one of the most popular languages for data science and statistical analysis. For data scientists, Python combines Java’s suitability for building high-traffic web applications with R’s focus on executing complex statistical functions.
Another one of Python’s strongest assets is its extensive set of libraries. These libraries can make it easier for developers to perform complex machine learning or statistical analysis tasks without having to rewrite many lines of code. Some of the most popular libraries include tools for data manipulation and visualization (NumPy, SciPy, and matplotlib), data mining and Natural Language Processing沙巴体育足球开户 (Pattern, NLTK). Perhaps unsurprisingly, Python is the language of choice for organizations with data-heavy workflows, from YouTube to the New York Stock Exchange to the National Web Service.
- It’s object-oriented.
- It’s cross-platform, working on Linux, Windows, Mac, and most other operating systems.
- Python’s standard library supports:
- HTML & XML
- E-mail processing
- HTTP Server libraries, easy for developing servers, and support for FTP, IMAP, and other Internet protocols
- It’s free and supported by an active open-source community.
- It’s often substituted for PHP in the LAMP software stack.
The Python developer’s toolbox
沙巴体育足球开户What should you look for in a Python engineer? Experience on large-scale, high-traffic applications is at the top of the list, along with fluency in SQL and database optimization. Common duties and core skills of Python developers include modular programming, object-oriented programming, and extensive experience with SQL.
A guide to Python web frameworks
Full-stack or microframework?
沙巴体育足球开户One of your main considerations in choosing a framework should be the size and complexity of your project. If you’re trying to get a feature-rich web app that will integrate with the rest of your organization’s systems, then a full-stack option could potentially save your team lots of time and effort. If, on the other hand, you’re working on a small, relatively simple project with few requirements, then a microframework might have everything you need.
A related question is how much “scaffolding” you need from a framework. A full-stack option should have just about everything you need to actually build a functioning web app–form generators, templating, access control lists, etc–so your team can assemble the pieces as needed. This is an attractive option for teams that are trying to get a product together quickly because it allows them to focus on actually building the app and not the stuff that goes around it. But if you have complex custom requirements or are working with a lot of customized software already, you may not be able to take advantage of all those libraries in the first place.
There are a bunch of full-stack options when it comes to Python frameworks. Some prominent examples include TurboGears 2, Pylons, and Web2py. That said, the most popular option, by far, is Django.
Django is the most popular Python framework around, and it’s easy to understand why. Thousands of websites are currently using Django, from daily newspapers to social media and sharing sites to major foundations and nonprofits. Since Django was originally developed for use in the newsroom, it’s no surprise that major daily publications like the Washington Post and The Guardian rely on it. Startups like Eventbrite and Disqus have turned to Django to scale quickly, while social media behemoths like Instagram and Pinterest have used it to power their dynamic web apps.
As a framework, Django is known for being fast to build and friendly沙巴体育足球开户 to beginning programmers. It’s a “batteries included” framework, meaning it supplies all the critical components you need–template rendering, ORM, authentication, routing, etc. It’s also exceedingly well-documented, which isn’t necessarily the case with some other popular frameworks.
沙巴体育足球开户By taking care of a lot of decisions, Django can dramatically speed up the time it takes to bootstrap a new project. What you gain in speed, though, you may lose in long-term flexibility. For example, Django’s built-in ORM is considered fine for a majority of cases, but it’s not as powerful an ORM as SQLAlchemy, which is widely viewed as the best Python database abstraction tool. While you can theoretically use SQLAlchemy with Django, you’ll lose a lot of the functionality that makes Django so appealing to begin with.
Web2py is another popular full-stack framework. One thing to keep in mind about Web2py is that it doesn’t support Python 3. The original developer of Web2py has promised a Python 3-compatible successor, but as of 2017 it hasn’t appeared.
Despite now being nearly a decade behind the latest version of Python, Web2py is still used by many major organizations, including a number of international banks. What makes this older framework still appealing for many developers? For one, it’s as easy to learn as Django, but also more flexible and extremely portable沙巴体育足球开户. The same code can run on just about any VPS with a SQL database or MongoDB, whether AWS or Google App Engine.
Web2py is extremely well supported with book-length documentation and a passionate community behind it. Another neat feature is that Web2py comes with its own IDE that includes a code editor, debugger, bug ticketing system, one-click deployment, and more. If your organization is committed to Python 2 for the foreseeable future or you plan to make use of some older Python libraries and software, then Web2py could suit your needs just fine.
Pyramid isn’t technically a full-stack framework. It instead bills itself as the “Goldilocks” framework, feature-rich without enforcing one way of doing things, lightweight without leaving you on your own as your app grows. It’s a favorite framework among many experienced Python developers thanks to its modularity and transparency, and has been used by small teams as well as tech giants like Dropbox, Yelp, SurveyMonkey, and Mozilla.
Practically speaking, nearly all of Pyramid’s components can be swapped out. You can choose how you connect to a database, or even what type (or types) of databases you want to be able to connect to. It doesn’t enforce certain choices for you the way Django does, and it also discourages the sort of “magic” features that handle certain tasks automatically but don’t always behave in a predictable or desirable manner.
沙巴体育足球开户Pyramid is often celebrated for its security system, which makes it easy to set up and check access control lists. Another point worth calling out is Pyramid’s Traversal system for mapping URLs to code, which can make building RESTful APIs much easier.
What if you don’t need the hand-holding or complexity of a full-stack framework? Many modern web apps require lots of moving parts, including database abstraction, form validation, and customized access control lists. But there are also plenty of web apps that don’t need any of that. For those kinds of projects, a microframework may be just what’s needed.
These ultra-lightweight frameworks are designed to get dead simple web apps up and running as quickly as possible. Their feature sets are minimal by design–anything functionality you could get by installing another library is deliberately left out. The plus side of this minimalist approach is that your code can be cleaner and your website faster. This is at least partly because microframeworks are generally less abstracted than full-stack frameworks. The code you write will be much closer to actual HTTP functions than with a more beginner-friendly framework.
Flask is probably the most popular microframework for Python, and one of the most popular Python frameworks, period. Like Django, it’s designed to get web apps up and running as quickly and painlessly as possible. Despite its small size, Flask has been used by big companies, including LinkedIn and Pinterest.
沙巴体育足球开户However, there’s a twist, which is that Flask is definitely suited to smaller, simpler projects than Django. Out of the box, you can expect a development web server, built-in unit testing, and support for Google App Engine. Now here’s a taste of what you won’t find in vanilla Flask: There’s no database abstraction layer, form validation, authentication, or upload handling, though all these features can be added through extensions. Some of the more common setups include Jinja2 for templating and CouchDB or SQLAlchemy for the database.
Some Python developers prefer Flask to Django because Flask is more “pythonic,” in that it mostly sticks to the Python mantra of there being one way to do something and that code should be explicit about what it’s doing. If you value clean code and don’t mind coding closer to the metal, then Flask may be a good option.
Bottle is another popular microframework. It was originally designed for building web APIs, and that’s still a good use case for it. What’s novel about Bottle is it tries to implement everything in one single file, which should give you an idea of how “micro” it’s designed to be. Out of the box it comes with routing, templating, utilities, and some basic abstraction over the WSGI standard. As with Flask, you’ll be coding much closer to the metal than with a full-stack framework. Despite its small size, Bottle has been used by the Netflix team to build web interfaces.
Python vs. Ruby
First, the similarities
沙巴体育足球开户Both are high-level, server-side scripting languages focusing on simplicity and prioritizing rapid development—getting things done fast, in fewer lines of code. These scripts eschew verbose code, strict hierarchy, and syntax correctness for more behind-the-scenes, object-oriented logic.
They’re used by entrepreneurs and startups alike to rapidly whip up web apps and prototypes, thanks to standard libraries, persistence support, and feature-packed frameworks—Python’s Django framework, and Ruby’s Ruby on Rails. Both are interpreted scripting languages, which means they don’t require a compiler like Scala or C++ do. Compiled languages tend to run faster, though. Rule of thumb? What you get in speed of development, you lose in runtime speed.
Now, let’s dive into their differences, starting with Ruby.
Ruby & the Ruby on Rails framework
沙巴体育足球开户Created in 1995, Ruby is object-oriented to its core, influenced by languages like C++, Perl, and Java. Here’s a look at Ruby, a language that’s ideal for collaboration, speed, and businesses that want a programming language that thinks as fast as they do.
Preferred for: Web development, functional programming
Philosophy: “Do more with less.” Developer freedom and flexibility, and more than one way to do things—something it inherited from Perl
Why developers love Ruby: Loose and creative coding, frequent updates, freedom and flexibility, and readable code that’s never confusing
Python & the Django framework
沙巴体育足球开户Python is all about efficiency and supporting calculation-heavy applications used in the fields of data and science. Along with its Django framework, Python enables super fast development.
Preferred for: Academic and scientific programming. Python has a slew of libraries for data work.
Philosophy:沙巴体育足球开户 “One right way to do things”
Why developers love Python: Stability over change, conservative code, fewer updates