Process Images Using the Pillow Library and Python

When you look at an image, you see the objects and people in it. However, when you read an image programmatically with Python or any other language, the computer sees an array of numbers. In this video course, you’ll learn how to manipulate images and perform basic image processing using the Python Pillow library. Pillow and its predecessor, PIL, are the original Python libraries for dealing with images. Even though there are other Python libraries for image processing, Pillow remains […]

Read more

What Are Python Asterisk and Slash Special Parameters For?

Whenever you think of Python’s asterisk operator (*), you most likely think of multiplication or exponentiation. Similarly, you probably associate the forward slash operator (/) with division. But you can also use the bare asterisk and slash as special parameters in function headers. These do something completely unrelated to mathematics. When defining functions, you’ll often include a list of comma-separated parameters to define what types of arguments the user can pass to your function. Using the asterisk and forward slash […]

Read more

Prompt Engineering: A Practical Example

You’ve used ChatGPT, and you understand the potential of using a large language model (LLM) to assist you in your tasks. Maybe you’re already working on an LLM-supported application and read about prompt engineering, but you’re unsure how to translate the theoretical concepts into a practical example. Your text prompt instructs the LLM’s responses, so tweaking it can get you vastly different output. In this tutorial, you’ll apply multiple prompt engineering techniques to a real-world example. You’ll experience prompt engineering […]

Read more

What Does if __name__ == “__main__” Mean in Python?

You’ve likely encountered Python’s if __name__ == “__main__” idiom when reading other people’s code. You might have even used if __name__ == “__main__” in your own scripts. But did you use it correctly? This line of code can seem a little cryptic, so don’t fret if you’re not completely sure what it does, why you might want it, and when to use it. In this video course, you’ll learn all about Python’s if __name__ == “__main__” idiom. What’s Included: Downloadable […]

Read more

Python News: What’s New From July 2023

It’s always a good month to be a Pythonista, but July 2023 really drove this point home! The release of a new Python 3.12 beta version and Cython 3.0 moved the language forward, and more change is on the way with the steering council’s announcement that a no-GIL CPython is in the works. Development in the Python world is a collective effort, with big contributions coming not from only the core developers but also everyday programmers. Sharing ideas is key […]

Read more

Working With the Python operator Module

In this section, you’ll learn about three of the higher-order functions that Python’s operator module makes available to you: itemgetter(), attrgetter(), and methodcaller(). You’ll learn how these allow you to work with Python collections in a range of useful ways that encourage a functional style of Python programming. Selecting Values From Multidimensional Collections With itemgetter() The first function that you’ll learn about is operator.itemgetter(). In its basic form, you pass it a single parameter that represents an index. Then itemgetter() […]

Read more

Reversing Strings in Python

When you’re using Python strings often in your code, you may face the need to work with them in reverse order. Python includes a few handy tools and techniques that can help you out in these situations. With them, you’ll be able to build reversed copies of existing strings quickly and efficiently. Knowing about these tools and techniques for reversing strings in Python will help you improve your proficiency as a Python developer. In this video course, you’ll learn how […]

Read more

How to Download Files From URLs With Python

When it comes to file retrieval, Python offers a robust set of tools and packages that are useful in a variety of applications, from web scraping to automating scripts and analyzing retrieved data. Downloading files from a URL programmatically is a useful skill to learn for various programming and data projects and workflows. In this tutorial, you’ll learn how to: Download files from the Web using the standard library as well as third-party libraries in Python Stream data to download […]

Read more

Python 3.12 Preview: More Intuitive and Consistent F-Strings

Every new Python version brings many changes, updates, fixes, and new features. Python 3.12 will be the next minor version and is now in the beta phase. In this version, the core team has been working intensely to formalize and improve the syntax and behavior of one of the most popular Python features: f-strings. F-strings, short for formatted strings, are string literals prefixed by either a lowercase or uppercase letter F. These strings provide a concise and clean syntax that […]

Read more

Socket Programming in Python Part 1: Handling Connections

Sockets and the socket API are used to send messages across a network. They provide a form of inter-process communication (IPC). The network can be a logical, local network to the computer, or one that’s physically connected to an external network, with its own connections to other networks. The obvious example is the Internet, which you connect to with your ISP. In this two-part series, you’ll create: A simple socket server and client An improved version that handles multiple connections […]

Read more
1 84 85 86 87 88 908