Python tutorials

Python Basics Exercises: Dictionaries

In plain English, a dictionary is a book containing the definitions of words. Each entry in a dictionary has two parts: the word being defined, and its definition. Python dictionaries, like lists and tuples, store a collection of objects. However, instead of storing objects in a sequence, dictionaries hold information in pairs of data called key-value pairs. That is, each object in a dictionary has two parts: a key and a value. Each key is assigned a single value, which […]

Read more

Python News: What’s New From February 2024

As February takes a rare leap forward with an extra day this year, the Python community followed suit! Python versions 3.12 and 3.11 receive a security fix, and CPython source distributions now document the software supply chain to allow for a more effective vulnerability detection. Another Rust-based tool makes its way into the Python ecosystem, promising exciting improvements to the existing package management system. Looking ahead, the reveal of the PyCon US 2024 schedule gives us a glimpse into the […]

Read more

Build an LLM RAG Chatbot With LangChain

You’ve likely interacted with large language models (LLMs), like the ones behind OpenAI’s ChatGPT, and experienced their remarkable ability to answer questions, summarize documents, write code, and much more. While LLMs are remarkable by themselves, with a little programming knowledge, you can leverage libraries like LangChain to create your own LLM-powered chatbots that can do just about anything. In an enterprise setting, one of the most popular ways to create an LLM-powered chatbot is through retrieval-augmented generation (RAG). When you […]

Read more

Creating Asynchronous Tasks With Celery and Django

You’ve built a shiny Django app and want to release it to the public, but you’re worried about time-intensive tasks that are part of your app’s workflow. You don’t want your users to have a negative experience navigating your app. You can integrate Celery to help with that. Celery is a distributed task queue for UNIX systems. It allows you to offload work from your Python app. Once you integrate Celery into your app, you can send time-intensive tasks to […]

Read more

Python’s __all__: Packages, Modules, and Wildcard Imports

Python has something called wildcard imports, which look like from module import *. This type of import allows you to quickly get all the objects from a module into your namespace. However, using this import on a package can be confusing because it’s not clear what you want to import: subpackages, modules, objects? Python has the __all__ variable to work around this issue. The __all__ variable is a list of strings where each string represents the name of a variable, […]

Read more

Jevons Paradox doesn’t always apply to software

When it comes to fighting climate change, I strongly believe that getting involved in politics is one of the most useful things you can do. But given how energy-intensive software is these days, writing more efficient software also seems worth doing, especially if your software is used at scale. However, whenever efficiency is brought up, Jevons Paradox rears its head. Writing in the 19th century, Jevons pointed out that increased efficiency in the use of coal didn’t decrease the amount […]

Read more

Python’s Requests Library (Guide)

Watch Now This tutorial has a related video course created by the Real Python team. Watch it together with the written tutorial to deepen your understanding: Making HTTP Requests With Python The Requests library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data in your application. Throughout this tutorial, you’ll see some of the […]

Read more

Python Basics Exercises: Installing Packages With pip

So far on the Python Basics learning path, you’ve been working within the bounds of the Python standard library. Now it’s time to unlock packages that aren’t included with Python by default. To do that, you’ll need pip. Many programming languages offer a package manager that automates the process of installing, upgrading, and removing third-party packages. Python is no exception. The de facto package manager for Python is called pip. In this Python Basics Exercises course, you’ll test and reinforce […]

Read more

Duck Typing in Python: Writing Flexible and Decoupled Code

Python makes extensive use of a type system known as duck typing. The system is based on objects’ behaviors and interfaces. Many built-in classes and tools support this type system, which makes them pretty flexible and decoupled. Duck typing is a core concept in Python. Learning about the topic will help you understand how the language works and, more importantly, how to use this approach in your own code. In this tutorial, you’ll learn: What duck typing is and what […]

Read more

What can you do about climate change?

Climate change is impacting the whole planet, and getting worse every year. So you want to do something—but you’re not sure what. If you do some research you might encounter an essay by Bret Victor—What can a technologist do about climate change? There’s a whole pile of good ideas in there, and it’s worth reading, but the short version is that you can use technology to “create options for policy-makers.” And working on clean energy or efficiency is definitely a […]

Read more
1 19 20 21 22 23 182