This post is from Grokking Python, a free newsletter available on Substack from Educative, the world’s best learning platform for software developers. It’s where we’ll share our team’s best Python-related info and resources — stuff we think could really enhance your understanding.
Hey Grokking Python readers!
Question for you: Once you’ve mastered Python, what will you do with it?
If you’re in a career where Python is used—and plan to stay there—you may already have a clear answer to this question. But if you’re just starting or are weighing some career-change options, your answer may be a little murkier. And that’s not the best way to undertake a learning journey.
Evidence shows that setting specific goals boosts motivation and learning effectiveness. Learning works best if you understand how you’ll apply the material and can take on relevant, real-world projects as early as possible.
So in the future, some issues of Grokking Python will focus on helping you wrap your head around what you can do with Python. These issues will form a series called Python in Action! In this series, we'll be addressing a wide range of disciplines where Python is used.
Our first installment is about one of Python’s most well-known use cases: web development.
Web development defined
Web development refers to creating, deploying, and operating a website or web application—basically, anything that needs to be hosted on a server.
It’s a catch-all term encompassing everything from simple, static web pages to the complex applications that power online businesses.
Web development has two areas, the front-end (or client-side) and the back-end (or server-side).
Front-end web developers are responsible for handling a website's aesthetic and interactive elements. Front-end web developers create intuitive layouts, navigation tools, eyecatching animations, buttons, and more! These are some of the languages that front-end developers use to design and develop:
- HTML (HyperText Markup Language) handles displaying and structuring content in web browsers. HTML props up websites in the same way a skeleton props up a body.
- CSS (Cascading Style Sheets) defines the visual elements of a website like color, fonts, and the layout of the HTML content. CSS would be like the skin and clothes on a body.
- JavaScript is what makes a website interactive and dynamic! It is used in the back-end as well as the front-end. You can think of JavaScript as being the muscles and nervous system of a body.
Back-end web developers make sure that requests made by users on the front-end of a website are fulfilled. These requests send, retrieve, and update data to servers and databases in the back-end. Back-end web developers work on these unseen aspects of the website to facilitate the functionality of any dynamic or interactive elements.
Some popular back-end languages include Ruby, PHP, Java, and Python!
Back-end web development is where Python really shines.
Python in the wild
Where might you have already encountered Python for web development in the wild? 🐍 A better question might be, where can you go on the internet without encountering functionality powered by Python? It’s probably not a long list.
Tons of big internet companies you come in contact with everyday use Python on the back end. Here are just a few:
- Google: It may be apocryphal, but some claim Google co-founders Larry Page and Sergey Brin vowed from the start to use “Python where we can, C++ where we must.” Python’s elegance, readability, and ease of use made it the team’s go-to except when performance really mattered.
- Instagram: The Python framework Django has played a key role in Instagram’s tech stack since the app’s creation in 2010. The speed with which Django apps can be prototyped and developed made it an obvious choice early on. The surprise (to some) was that the framework proved scalable enough to support Instagram’s rapid growth—even to the present day (1 billion users and counting!).
- Netflix: Python is used for just about everything at Netflix. Use cases you’ve likely experienced include: 1) training machine learning models to make content recommendations and 2) building a regional failover system to cut response time during service outages. The word on the street is that Netflix gives developers maximum autonomy in selecting programming languages—and most choose Python due to its simplicity and access to countless tools and libraries.
How is Python used in web development?
As we mentioned earlier, Python’s role in web development centers on the website’s back end. Python has a massive collection of frameworks and libraries that allow web developers to execute advanced features without programming them from scratch. Web developers using Python benefit from having reusable components that can be used to build out APIs and websites quickly and efficiently.
You can use Python (along with handy frameworks like Django and Flask) to create just about any back-end logic your website needs to function. That includes adding:
- Built-in development servers and debuggers
- Database access
- Authentication systems
- HTML structure validation
- Content management
- Data authorization
- Localization support
- And lots more, depending on what functionality your website or app requires
For more about Python’s use in web development (including suggested tools and what to learn), check out this article from the Educative blog.
As we shared in our last newsletter, Python’s role in web development may be poised to grow even more prominent thanks to the recent launch of PyScript.
PyScript is a system for interleaving Python in HTML (similar to PHP) that lets web developers use Python and all its libraries in the browser. That means it’s now possible to create an entire web application (including the front end) using nothing but Python.
Useful frameworks, libraries, and packages
Python boasts an enormous and highly active user community that’s constantly building and refining open-source frameworks and libraries.
No matter what problem you’re trying to solve, there’s probably already a free and readily available tool that can handle it. The only downside is that there are so, so many that it can get kind of overwhelming.
While just about anyone can pick up Python in an afternoon, getting to know the vast ecosystem of packages that make Python great can be much more time-consuming.
To simplify things a bit, here’s a handful of Python frameworks, libraries, and packages that web developers (and those aspiring) should know about:
- Flask: A lightweight microframework offering “just the essentials” for web development. Developers often choose Flask for smaller projects and microservices. Want to hit the ground running with simple, achievable projects and grow from there?.
- Django: A robust, “batteries included” framework typically used for more complex web development projects. Check out this article on Educative to learn more about how Django and Flask differ.
- Pyramid: Another framework option for web developers, Pyramid is more flexible than Django but more full-featured than Flask.
- Bottle: Yet another minimalistic microframework for small applications. Bottle is often used for building APIs.
- Web2Py: A full-stack web development framework with its own web-based IDE.
- Requests: A library that simplifies the process of sending HTTP requests in Python.
- Beautiful Soup: A library for getting data out of HTML, XML, and other markup languages. BS4 is popular for web scraping.
Project ideas: learn by doing
The best way to grow your Python web development skillset is to put it to work. Here are a few project ideas to get you started:
- Visualize stock market data using Python libraries.
- Build a custom chatbot using Python, NLTK, and TensorFlow.
- Build a content aggregator for your favorite news sites.
- Build a complete web application using Python (with Flask) for the back end and React for the front end.
- Build a custom URL shortener. There are many tutorials out there, so find one that uses the libraries you’re most interested in learning.
- Build an Instagram or Twitter bot that posts on your behalf.
Is there a Python use-case you’d like us to cover in a future installment of Python in Action? Let us know in the comments or by replying to this email.
As always, happy learning!
Start a discussion
Where else do you see Python in action? Was this article helpful? Let us know in the comments below!