A Python namespace is a mapping from names to objects. It works like a dictionary where keys are object names and values are the objects themselves. Namespaces organize variables and functions in a dedicated space, allowing you to use multiple instances of the same name without conflict, as long as they’re in different namespaces. In this tutorial, you’ll explore the different types of namespaces in Python, including the built-in, global, local, and enclosing namespaces. You’ll also learn how they define the scope of names and influence name resolution in Python programs. By the end of this…
Python’s for loop allows you to iterate over the items in a collection, such as lists, tuples, strings, and dictionaries. The for loop syntax declares a loop variable that takes each item from the collection in each iteration. This loop is ideal for repeatedly executing a block of code on each item in the collection. You can also tweak for loops further with features like break, continue, and else. By the end of this tutorial, you’ll understand that: Python’s for loop iterates over items in a data collection, allowing you to execute code for each item. To iterate from 0 to 10, you use the for…
In this quiz, you’ll test your understanding of How to Get a List of All Files in a Directory With Python. By working through this quiz, you’ll revisit how .iterdir() hands you the contents of a single directory, how glob patterns let .glob() and .rglob() filter results by name, and how .rglob() walks an entire directory tree. You’ll also check your understanding of filtering on attributes with comprehensions and filter(), and of skipping junk directories instead of listing every file inside them. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to…
Transformers is a powerful Python library created by Hugging Face that allows you to download, manipulate, and run thousands of pretrained, open-source AI models. These models cover multiple tasks across modalities like natural language processing, computer vision, audio, and multimodal learning. Using pretrained open-source models can reduce costs, save the time needed to train models from scratch, and give you more control over the models you deploy. By the end of this tutorial, you’ll understand that: Hugging Face Transformers is a Python library for downloading and running pretrained…
Selenium is a web automation tool that allows you to use Python to programmatically interact with dynamic, JavaScript-generated web pages. Your Python Selenium code drives a real browser that you can instruct to fill out forms, click buttons, scrape dynamically generated data, or write automated tests for web applications. By implementing the Page Object Model (POM) design pattern, you can create clean and scalable automation scripts that are straightforward to read and maintain. By the end of this tutorial, you’ll understand that: Selenium allows you to launch browsers, visit URLs, and…
You’ve probably asked ChatGPT for a picture and watched one appear a few seconds later. The same models also sit behind OpenAI’s GPT Image API, so you can generate images from your own Python code instead of a chat window. You send a prompt, and image data comes back for your script to work with. By the end of this tutorial, you’ll understand that: You generate images from a text prompt by calling client.images.generate() with a GPT Image model like gpt-image-2.5-flare. Image data always arrives Base64-encoded in .b64_json, so you save it as a file with b64decode(). You choose your image’s…
In this quiz, you’ll test your understanding of Python Basics Exercises: Strings and String Methods. By working through this quiz, you’ll revisit how to slice strings, change their case, strip whitespace, check how a string starts, chain string methods together, and format values for printing. Working with text is one of the most common tasks in Python, so these skills will come up again and again. Take your time with each question, and read the explanations to reinforce what you’ve practiced. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your…
In this quiz, you’ll test your understanding of Generate Images in Python With OpenAI’s GPT Image API. By working through this quiz, you’ll revisit how to install the OpenAI Python library, store your API key, generate images from text prompts with the GPT Image models, tune their size and quality, decode Base64 responses into PNG files, and edit an image with a follow-up prompt. [ 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 ]
How do you assemble the core pieces of a coding agent? How are developers defining projects through conversation and introspection? This week on the show, Geir Arne Hjelle returns to talk about his recent project to demonstrate how coding agents work under the hood. [ 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 ]
Meta recently released their new personal AI agent named Meta Muse. However, behind this name isn’t just “one thing”. Meta also uses the Muse name for an upcoming pocket gadget and for the AI models that programmers use to build apps. By the end of this tutorial, you’ll understand which Muse is which and whether it’s worth trying. No coding experience required. To see which part of Muse fits you, find your situation in the table below: Your situation Recommendation Want an assistant that answers questions and handles errands like shopping or booking travel The Muse app Want a pocket-sized…
When I talk to developers in stable, more senior roles, I keep noticing the same thing: many haven’t had time to properly try AI coding tools. If you’re a junior who’s spent the last few months experimenting, you may have more hands-on AI experience than they do. The reasons have nothing to do with senior developers being slow or stubborn. They come down to time and a kind of caution that I think is well placed. I talk about this, along with more advice for junior developers, in this community video: Free Starter Kit: Click here to get the Junior Dev AI Starter Kit with cheat sheets, a video…
In this quiz, you’ll test your understanding of Python, Boto3, and AWS S3: Demystified. By working through this quiz, you’ll revisit how to connect to S3 through a client or a resource, create buckets and objects, upload files, and configure storage classes and versioning. You’ll also check how to traverse your buckets, clear out a versioned bucket, and decide when to reach for Boto3 instead of an Infrastructure as Code tool. [ 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…
Choosing the best IDE or code editor for Python means weighing your skill level, project type, and workflow in a landscape that has changed dramatically in recent years. AI-first editors have arrived, and well-established tools have added AI integrations. This guide cuts through the noise and maps each tool to the situations where it fits best. The Python ecosystem now spans six categories of coding tools. You’ll walk through each one, learn what distinguishes the tools within each category, and end with a flowchart that maps common scenarios to concrete recommendations. Here’s a quick…
In this quiz, you’ll test your understanding of The Best IDEs and Code Editors for Python (Guide). By working through this quiz, you’ll revisit what separates a code editor from an IDE, which editor features catch problems before you run your code, and how beginner-friendly tools, full-featured IDEs, AI-first editors, notebook environments, terminal editors, and cloud workspaces each suit a different kind of work. [ 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 ]
If you’re curious about web development, then you’ve likely encountered the abbreviation MVC, which stands for Model-View-Controller. You may know that it’s a common design pattern that’s fundamental to many Python web frameworks and even desktop applications. But what exactly does it mean? If you’ve had a hard time wrapping your head around the concept, then this video course is for you. In this video course, you’ll: Learn what models, views, and controllers are conceptually Follow a user’s request through an MVC application from end to end Tie your conceptual understanding back to concrete…
In this quiz, you’ll test your understanding of Exploring the MVC Pattern in Python. By working through this quiz, you’ll revisit what models, views, and controllers are, how a user’s request travels through each of them, and how routes and templates tie the pattern together in a Flask app. Once the pattern clicks, you’ll have a mental map that carries over to Django and most other web frameworks you’ll meet. [ 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 ]
In this quiz, you’ll test your understanding of Using pandas and Python to Explore Your Dataset. By working through this quiz, you’ll revisit how to load a CSV file into a DataFrame, select and query your data with .loc and .iloc, group and aggregate values, handle missing data, and plot your results. The pandas library is one of the most popular tools for working with data in Python, so a solid foundation here will pay off. [ 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…
Python 3.15 was supposed to be the least surprising news of the month. The feature set has been locked since May, and our preview series has been walking through it all summer. Then a handful of last-minute bugs in lazy imports forced a surprise third release candidate, and the final release moved to October 9, later this week. The first-ever Python Packaging Council was elected and immediately handed a PEP written by one of its own members. PyPI changed how it counts downloads, so if your package’s chart just fell off a cliff, that’s the likely reason. Polars 2.0 reached the release…
In this quiz, you’ll test your understanding of How to Launch an HTTP Server in One Line of Python Code. By working through this quiz, you’ll revisit how to start Python’s http.server from the command line, bind it to an address and port, and choose which directory it shares. You’ll also check your knowledge of running CGI scripts, building a handler on top of BaseHTTPRequestHandler, serving over HTTPS, and knowing when to keep this server out of production. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click…
Python strings are a sequence of characters used for handling textual data. You can create strings in Python using quotation marks or the str() function, which converts objects into strings. Strings in Python are immutable, meaning once you define a string, you can’t change it. By the end of this tutorial, you’ll understand that: The str() function converts objects to their string representation. String interpolation in Python allows you to insert values into {} placeholders in strings using f-strings or the .format() method. You access string elements in Python using indexing with square…
Read at the source
Your visit, your choice.
Optional Google Analytics helps us understand visits. Microsoft Clarity records masked interactions to improve the site. Optional tools stay off unless you choose them. Privacy details.