Sneaky REST APIs With Django Ninja

Many web projects have moved to the single-page application model. To use this model with Django, you build a project where Django is the back end accessed through a REST API. The Django Ninja library is a FastAPI-inspired tool kit for turning Django views into REST API endpoints with very little extra code. Along the […]

Continue Reading

How to Add Python to PATH

You may need to add Python to PATH if you’ve installed Python, but typing python on the command line doesn’t seem to work. You may be getting a message saying that the term python isn’t recognized, or you may end up with the wrong version of Python running. A common fix for these problems is […]

Continue Reading

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

You’ve likely encountered Python’s if __name__ == “__main__” idiom when reading other people’s code. No wonder—it’s widespread! You might have even used if __name__ == “__main__” in your own scripts. But did you use it correctly? Maybe you’ve programmed in a C-family language like Java before, and you wonder whether this construct is a clumsy […]

Continue Reading

Building Python Project Documentation With MkDocs

In this course, you’ll learn how to quickly build documentation for a Python package using MkDocs and mkdocstrings. These tools allow you to generate nice-looking and modern documentation from Markdown files and your code’s docstrings. Maintaining auto-generated documentation means less effort because you’re linking information between your code and the documentation pages. However, good documentation […]

Continue Reading

When Do You Use an Ellipsis in Python?

In English writing, you can use the ellipsis to indicate that you’re leaving something out. Essentially, you use three dots (…) to replace the content. But the ellipsis doesn’t only exist in prose—you may have seen three dots in Python source code, too. The ellipsis literal (…) evaluates to Python’s Ellipsis. Because Ellipsis is a […]

Continue Reading

How to Replace a String in Python

If you’re looking for ways to remove or replace all or part of a string in Python, then this tutorial is for you. You’ll be taking a fictional chat room transcript and sanitizing it using both the .replace() method and the re.sub() function. In Python, the .replace() method and the re.sub() function are often used […]

Continue Reading