Python supports duck-typing, but it will not work on built-in types. forbiddenfruit allows adding or overwrite functions of built-in types such as int or str.
InventWithPython is Al Sweigart’s hub for beginner-friendly, project-based Python learning. The site publishes free online editions (Creative Commons) of his books—most notably "Automate the Boring Stuff with Python"—alongside titles such as "Invent Your Own Computer Games with Python", "Cracking Codes with Python", "Making Games with Python & Pygame", "The Recursive Book of Recursion", and more.
Resources include downloadable ebooks, video courses and Udemy discounts, the Simple Turtle Tutorial, YouTube series, example code, and open-source projects (e.g., PyAutoGUI, pyperclip). The author provides buy links for print/ebook editions and accepts donations (Patreon/PayPal) to support free distribution. Content emphasizes hands-on exercises, runnable source code, and small projects—making it well suited for students, hobbyists, educators, and non‑engineer professionals.
JupyterLite is a JupyterLab distribution that runs entirely in the browser. It supports a Python kernel using Pyodide and a JavaScript kernel.
Try JupyterLite Lab
The extract function copies the local variables from the current function frame into the existing Jupyter session. If the Python code crashes, you can enter the debugger with the %debug magic and then use the extract function to copy the variables from the function frame into the Jupyter session. The variables can now be properly inspected, e.g., plotted.
The original URI above contains more details how to use this post-mortem debugging.
def extract(source=None):
"""Copies the variables of the caller up to iPython. Useful for debugging.
.. code-block:: python
def f():
x = 'hello world'
extract()
f() # raises an error
print(x) # prints 'hello world'
"""
import inspect
import ctypes
if source is None:
frames = inspect.stack()
caller = frames[1].frame
name, ls, gs = caller.f_code.co_name, caller.f_locals, caller.f_globals
elif hasattr(source, '__func__'):
func = source.__func__
name, ls, gs = func.__qualname__, (func.__closure__ or {}), func.__globals__
elif hasattr(source, '__init__'):
func = source.__init__.__func__
name, ls, gs = func.__qualname__, (func.__closure__ or {}), func.__globals__
else:
raise ValueError(f'Don\'t support source {source}')
ipython = [f for f in inspect.stack() if f.filename.startswith('<ipython-input')][-1].frame
ipython.f_locals.update({k: v for k, v in gs.items() if k[:2] != '__'})
ipython.f_locals.update({k: v for k, v in ls.items() if k[:2] != '__'})
# Magic call to make the updates to f_locals 'stick'.
# More info: https://pydev.blogspot.co.uk/2014/02/changing-locals-of-frame-frameflocals.html
ctypes.pythonapi.PyFrame_LocalsToFast(ctypes.py_object(ipython), ctypes.c_int(0))
message = 'Copied {}\'s variables to {}'.format(name, ipython.f_code.co_name)
raise RuntimeError(message)
Format string overview for the old and new format string syntax in Python. It shows for each thing you might want to perform, the old syntax (if existing), the new syntax and the output.
Python has some gotchas that are good to know. The Python documentation has a whole page dedicated to non-intuitive and problematic behavior in Python, for example regarding mutable default arguments.
It contains a comprehensive list of tutorials, ranging from beginner to advanced. Moreover, it contains community interviews with well-known Python users, a list of Python books and quizzes.
A practical, continuously updated, handbook which provides insight into how to use Python, both as a beginner and as an expert.
angr is a python framework for analyzing binaries. It combines both static and dynamic symbolic ("concolic") analysis, making it applicable to various tasks.
pdoc is a Python API documentation generation, which turns doc-strings and type annotations into a simple and elegant documentation.
pdoc auto-generates API documentation that follows your project's Python module hierarchy. It requires no configuration, has first-class support for type annotations, cross-links between identifiers, comes with an integrated live-reloading web server, uses customizable HTML templates, understands numpydoc and Google-style docstrings, and is permissively licensed.
wtfpython is a collection of unintuitive Python snippets. Due to implementation details, some Python code does not behave obvious. The repository contains many such snippets and explains why the behavior occurs.