How to Format Floats Within F-Strings in Python
Real Python
by Real Python
20h ago
You’ll often need to format and round a Python float to display the results of your calculations neatly within strings. In earlier versions of Python, this was a messy thing to do because you needed to round your numbers first and then use either string concatenation or the old string formatting technique to do this for you. Since Python 3.6, the literal string interpolation, more commonly known as a formatted string literal or f-string, allows you to customize the content of your strings in a more readable way. An f-string is a literal string prefixed with a lowercase or uppercase letter f a ..read more
Visit website
Using raise for Effective Exceptions
Real Python
by Real Python
3d ago
In your Python journey, you’ll come across situations where you need to signal that something is going wrong in your code. For example, maybe a file doesn’t exist, a network or database connection fails, or your code gets invalid input. A common approach to tackle these issues is to raise an exception, notifying the user that an error has occurred. That’s what Python’s raise statement is for. Learning about the raise statement allows you to effectively handle errors and exceptional situations in your code. This way, you’ll develop more robust programs and higher-quality code. In this video cou ..read more
Visit website
The Real Python Podcast – Episode #200: Avoiding Error Culture and Getting Help Inside Python
Real Python
by Real Python
1w ago
What is error culture, and how do you avoid it within your organization? How do you navigate alert and notification fatigue? Hey, it's episode #200! Real Python's editor-in-chief, Dan Bader, joins us this week to celebrate. Christopher Trudeau also returns to bring another batch of PyCoder's Weekly articles and projects. [ Improve Your Python With ? Python Tricks ? – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ..read more
Visit website
Pydantic: Simplifying Data Validation in Python
Real Python
by Real Python
1w ago
Pydantic is a powerful data validation and settings management library for Python, engineered to enhance the robustness and reliability of your codebase. From basic tasks, such as checking whether a variable is an integer, to more complex tasks, like ensuring highly-nested dictionary keys and values have the correct data types, Pydantic can handle just about any data validation scenario with minimal boilerplate code. In this tutorial, you’ll learn how to: Work with data schemas with Pydantic’s BaseModel Write custom validators for complex use cases Validate function arguments with Pydantic’s ..read more
Visit website
Generating QR Codes With Python
Real Python
by Real Python
1w ago
From restaurant e-menus to airline boarding passes, QR codes have numerous applications that impact your day-to-day life and enrich the user’s experience. Wouldn’t it be great to make them look good, too? With the help of this video course, you’ll learn how to use Python to generate beautiful QR codes for your personal use case. In its most basic format, a QR code contains black squares and dots on a white background, with information that any smartphone or device with a dedicated QR scanner can decode. Unlike a traditional bar code, which holds information horizontally, a QR code holds the da ..read more
Visit website
Python News: What's New From March 2024
Real Python
by Real Python
1w ago
While many people went hunting for Easter eggs, the Python community stayed active through March 2024. The free-threaded Python project reached a new milestone, and you can now experiment with disabling the GIL in your interpreter. The Python Software Foundation does a great job supporting the language with limited resources. They’ve now announced a new position that will support users of PyPI. NumPy is an old workhorse in the data science space. The library is getting a big facelift, and the first release candidate of NumPy 2 is now available. Dive in to learn more about last month’s most im ..read more
Visit website
The Real Python Podcast – Episode #199: Leveraging Documents and Data to Create a Custom LLM Chatbot
Real Python
by Real Python
1w ago
How do you customize a LLM chatbot to address a collection of documents and data? What tools and techniques can you use to build embeddings into a vector database? This week on the show, Calvin Hendryx-Parker is back to discuss developing an AI-powered, Large Language Model-driven chat interface. [ Improve Your Python With ? Python Tricks ? – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ..read more
Visit website
Install and Execute Python Applications Using pipx
Real Python
by Real Python
2w ago
A straightforward way to distribute desktop and command-line applications written in Python is to publish them on the Python Package Index (PyPI), which hosts hundreds of thousands of third-party packages. Many of these packages include runnable scripts, but using them requires decent familiarity with the Python ecosystem. With pipx, you can safely install and execute such applications without affecting your global Python interpreter. In this tutorial, you’ll learn how to: Turn the Python Package Index (PyPI) into an app marketplace Run installed applications without explicitly calling Pytho ..read more
Visit website
Python Deep Learning: PyTorch vs Tensorflow
Real Python
by Real Python
2w ago
PyTorch vs TensorFlow: What’s the difference? Both are open source Python libraries that use graphs to perform numerical computation on data. Both are used extensively in academic research and commercial code. Both are extended by a variety of APIs, cloud computing platforms, and model repositories. If they’re so similar, then which one is best for your project? In this video course, you’ll learn: What the differences are between PyTorch and TensorFlow What tools and resources are available for each How to choose the best option for your specific use case You’ll start by taking a close look ..read more
Visit website
The Real Python Podcast – Episode #198: Build a Video Game With Python Turtle & Visualize Data in Seaborn
Real Python
by Real Python
2w ago
Can you build a Space Invaders clone using Python's built-in turtle module? What advantages does the Seaborn data visualization library provide compared to Matplotlib? Christopher Trudeau is back on the show this week, along with special guest Real Python core team member Bartosz Zaczyński. We're sharing another batch of PyCoder's Weekly articles and projects. [ Improve Your Python With ? Python Tricks ? – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ..read more
Visit website

Follow Real Python on FeedSpot

Continue with Google
Continue with Apple
OR