diff --git a/docs/classes.md b/docs/classes.md index d0b37e8..b9e94f8 100644 --- a/docs/classes.md +++ b/docs/classes.md @@ -6,6 +6,8 @@ description: >- # :material-package-variant:{ .lg .middle } Classes +
+ A **class** bundles related data together with the behavior (methods) that acts on it, instead of keeping them separate. A [dictionary](collections.md#dictionaries) can already hold a snake's data as key-value pairs — a class goes one step further, pairing that data with the functions that work on it. Structuring code this way is called **object-oriented programming (OOP)**. | Concept | Example | What it is | @@ -16,6 +18,8 @@ A **class** bundles related data together with the behavior (methods) that acts | Method | `def describe(self):` | A function that belongs to a class and acts on a specific object | | Inheritance | `class Boa(Snake):` | A new class that reuses — and can extend or override — another class's attributes and methods | +
+
## Defining a class diff --git a/docs/collections.md b/docs/collections.md index 7292b7c..340c727 100644 --- a/docs/collections.md +++ b/docs/collections.md @@ -6,6 +6,8 @@ description: >- # :material-basket-outline:{ .lg .middle } Collection Data Types +
+ A **collection** is a single object that groups multiple values (like [basic types](types.md)) together and so they can be stored in one variable together and worked with as a unit.
@@ -33,7 +35,9 @@ A **collection** is a single object that groups multiple values (like [basic typ isinstance(weights, list) # True isinstance(weights, dict) # False ``` - + +
+
## Lists diff --git a/docs/conditionals.md b/docs/conditionals.md index cda4e7f..2d28ac0 100644 --- a/docs/conditionals.md +++ b/docs/conditionals.md @@ -6,6 +6,8 @@ description: >- # :material-source-branch:{ .lg .middle } Conditionals +
+ A **conditional** lets a program make decisions by running a **block** of code only when a [condition](#boolean-expressions) is `True`. The condition ends with a colon `:`, and the block is the lines indented underneath it, treated as a single unit. @@ -21,6 +23,8 @@ The condition ends with a colon `:`, and the block is the lines indented underne
+
+
## If / elif / else diff --git a/docs/errors.md b/docs/errors.md index f96ecf8..cc69bea 100644 --- a/docs/errors.md +++ b/docs/errors.md @@ -6,6 +6,8 @@ description: >- # :material-bug-outline:{ .lg .middle } Errors +
+ **"Errors"** occur when a line of code is impossible to run, so the program stops and displays a message with information on what went wrong and where. **"Bugs"** are the general term for errors or *any mistake* in your code, like logic errors. @@ -26,6 +28,8 @@ They are part of programming, and happen constantly. Based on the kind of error, ## Kinds of errors: +
+
### Syntax errors { .pt-fake-h2 } diff --git a/docs/files.md b/docs/files.md index 8204514..58770e7 100644 --- a/docs/files.md +++ b/docs/files.md @@ -6,6 +6,8 @@ description: >- # :material-file-document-outline:{ .lg .middle } File Read/Write +
+ Instead of only printing output to the terminal, you can have the program save data to a file on your computer so data stays after the program ends, or read data from a file. For how to pull code **from another `.py` file** into your program, that's in [Modules & Imports](modules.md#importing-modules). @@ -25,6 +27,8 @@ flowchart LR
+
+
## Opening and closing files diff --git a/docs/functions.md b/docs/functions.md index b97b097..4b095fd 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -6,6 +6,8 @@ description: >- # :material-function-variant:{ .lg .middle } Functions +
+ A **function** packages a block of code under a name, so it can be run again — with different inputs — instead of copying and pasting the same lines every time you need them. Python already has some built in (`print()`, `len()`, `input()`), but `def` lets you write your own. @@ -95,6 +97,8 @@ message = describe("ball") # "a ball python" is the return value, so now print(is_unusually_long("ball python", 6)) ``` +
+
## Defining a function diff --git a/docs/img/header_dark.svg b/docs/img/header_dark.svg new file mode 100644 index 0000000..6f5d5d6 --- /dev/null +++ b/docs/img/header_dark.svg @@ -0,0 +1,7986 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/img/header_light.svg b/docs/img/header_light.svg new file mode 100644 index 0000000..3f81041 --- /dev/null +++ b/docs/img/header_light.svg @@ -0,0 +1,7986 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/javascripts/essentials_toggle.js b/docs/javascripts/essentials_toggle.js index 5f9a318..561d58d 100644 --- a/docs/javascripts/essentials_toggle.js +++ b/docs/javascripts/essentials_toggle.js @@ -63,11 +63,19 @@ }); } - // Disappearing confirmation toast for the Essentials/Advanced toggle — - // the toggle itself only shows the current state, not what just changed, - // so a click gives no feedback about its actual effect otherwise. + // Disappearing confirmation toast, shared by the Essentials/Advanced + // toggle and the light/dark toggle — neither toggle's own button shows + // what just changed, only the current state, so a click otherwise gives + // no feedback about its actual effect. + // + // `iconAttrs` is the dataset to put on the icon span, e.g. {mode: + // "simplified"} or {scheme: "slate"} — matched in extra.css by + // .pt-mode-icon[data-mode] / [data-scheme] to the same icons the + // triggering toggle itself uses. `body` is optional; pass "" to show a + // one-line toast (the light/dark toggle's own message is self- + // explanatory, unlike the Essentials/Advanced one). let toastTimer = null; - function showToast(active) { + function showToast(label, iconAttrs, body) { let toast = document.getElementById("pt-toast"); if (!toast) { toast = document.createElement("div"); @@ -87,17 +95,19 @@ title.className = "pt-toast__title"; const icon = document.createElement("span"); icon.className = "pt-mode-icon"; - icon.dataset.mode = active ? "simplified" : "advanced"; + Object.keys(iconAttrs).forEach(function (key) { + icon.dataset[key] = iconAttrs[key]; + }); icon.setAttribute("aria-hidden", "true"); - title.append(active ? "Essentials " : "Advanced ", icon); - - const body = document.createElement("div"); - body.className = "pt-toast__body"; - body.textContent = active - ? "Just the basics, start here!" - : "Viewing all content."; - - toast.append(title, body); + title.append(label + " ", icon); + toast.append(title); + + if (body) { + const bodyEl = document.createElement("div"); + bodyEl.className = "pt-toast__body"; + bodyEl.textContent = body; + toast.append(bodyEl); + } // The header's own height isn't fixed across breakpoints (taller with // the tab bar on tablet/desktop) or over time (Material can hide/reveal @@ -108,8 +118,9 @@ toast.style.top = Math.max(headerBottom, 0) + 12 + "px"; // Retrigger the transition even if a toast is already showing (rapid - // clicks between the two options): drop the class, force layout, then - // re-add it, instead of just extending the existing timer. + // clicks between the two options, or switching from one toggle to the + // other): drop the class, force layout, then re-add it, instead of + // just extending the existing timer. toast.classList.remove("pt-toast--visible"); void toast.offsetWidth; toast.classList.add("pt-toast--visible"); @@ -180,7 +191,11 @@ if (next === wasActive) return; localStorage.setItem(STORAGE_KEY, String(next)); applyState(container, next); - showToast(next); + showToast( + next ? "Essentials" : "Advanced", + { mode: next ? "simplified" : "advanced" }, + next ? "Just the basics, start here!" : "Viewing all content." + ); }); return container; @@ -233,12 +248,13 @@ container.addEventListener("click", function (event) { const option = event.target.closest(".pt-theme-option"); if (!option) return; - const radio = option.dataset.scheme === "slate" ? darkRadio : lightRadio; - if (!radio.checked) { - radio.checked = true; - radio.dispatchEvent(new Event("change", { bubbles: true })); - } + const scheme = option.dataset.scheme; + const radio = scheme === "slate" ? darkRadio : lightRadio; + if (radio.checked) return; + radio.checked = true; + radio.dispatchEvent(new Event("change", { bubbles: true })); applyThemeState(container); + showToast(scheme === "slate" ? "Lights off" : "Lights on", { scheme: scheme }, ""); }); // Sync to whatever scheme Material's own JS actually lands on, not diff --git a/docs/libraries/beautifulsoup.md b/docs/libraries/beautifulsoup.md index c19baa5..3cb65da 100644 --- a/docs/libraries/beautifulsoup.md +++ b/docs/libraries/beautifulsoup.md @@ -6,12 +6,16 @@ description: >- # :material-pot-steam-outline:{ .lg .middle } BeautifulSoup library +
+ [BeautifulSoup documentation :material-open-in-new:](https://www.crummy.com/software/BeautifulSoup/bs4/doc/){ .md-button target="_blank" } BeautifulSoup is an open-source project maintained by volunteer contributors. **BeautifulSoup** (imported from `bs4`) is a popular library for parsing HTML — turning a page's raw markup into something you can search by tag, class, or attribute instead of scanning raw text by hand. It's a third-party package, not part of the standard library, but it's the de facto standard for this in Python. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/collections.md b/docs/libraries/collections.md index 51862aa..da92211 100644 --- a/docs/libraries/collections.md +++ b/docs/libraries/collections.md @@ -6,6 +6,8 @@ description: >- # :material-format-list-group:{ .lg .middle } collections library +
+ [collections documentation :material-open-in-new:](https://docs.python.org/3/library/collections.html){ .md-button target="_blank" } !!! note "Not the same as the Collections page" @@ -32,6 +34,8 @@ built-in [`str`](../types.md#strings) [`list`](../collections.md#lists) [`dict`]
+
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/csv.md b/docs/libraries/csv.md index bda931d..fc98ecc 100644 --- a/docs/libraries/csv.md +++ b/docs/libraries/csv.md @@ -6,10 +6,14 @@ description: >- # :material-file-delimited-outline:{ .lg .middle } csv library +
+ [csv documentation :material-open-in-new:](https://docs.python.org/3/library/csv.html){ .md-button target="_blank" } The **`csv`** module reads and writes CSV ("comma-separated values") files — a plain-text table format that spreadsheets and databases can both open. Every example below actually runs in your browser: Pyodide gives each page its own in-memory filesystem, so `open()` works exactly like it would on a real computer, just without anything being saved outside this page. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/datetime.md b/docs/libraries/datetime.md index 462f078..93e7fb0 100644 --- a/docs/libraries/datetime.md +++ b/docs/libraries/datetime.md @@ -6,6 +6,8 @@ description: >- # :material-calendar-clock:{ .lg .middle } datetime library +
+ [datetime documentation :material-open-in-new:](https://docs.python.org/3/library/datetime.html){ .md-button target="_blank" } The **`datetime`** module is Python's standard library for working with dates and times — logging when an observation happened, measuring how long ago it was, or formatting a date for display. @@ -17,6 +19,8 @@ The **`datetime`** module is Python's standard library for working with dates an | Timezone support | Full — handles timezone-aware dates and conversions. | Limited — relies on the system's local time. | | Common uses |
  • Logging when something happened
  • Calculating an age or a deadline
  • Date arithmetic
|
  • Benchmarking how long code takes to run
  • Pausing a program with `sleep()`
| +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/json.md b/docs/libraries/json.md index 377ac76..f03ec48 100644 --- a/docs/libraries/json.md +++ b/docs/libraries/json.md @@ -6,10 +6,14 @@ description: >- # :material-code-json:{ .lg .middle } json library +
+ [json documentation :material-open-in-new:](https://docs.python.org/3/library/json.html){ .md-button target="_blank" } The **`json`** module reads and writes JSON ("JavaScript Object Notation") data — a plain-text format for structured data, whose objects and arrays map naturally to Python dicts and lists, which makes it the standard way structured data moves between programs, files, and web APIs. Every example below actually runs in your browser: Pyodide gives each page its own in-memory filesystem, so `open()` works exactly like it would on a real computer, just without anything being saved outside this page. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/math.md b/docs/libraries/math.md index 596b162..af09f87 100644 --- a/docs/libraries/math.md +++ b/docs/libraries/math.md @@ -6,10 +6,14 @@ description: >- # :material-square-root-box:{ .lg .middle } math library +
+ [math documentation :material-open-in-new:](https://docs.python.org/3/library/math.html){ .md-button target="_blank" } The **`math`** module extends Python's built-in arithmetic with functions it doesn't provide directly — square roots, rounding modes, constants like pi, and logarithms. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/matplotlib.md b/docs/libraries/matplotlib.md index 17ca861..bf1ac57 100644 --- a/docs/libraries/matplotlib.md +++ b/docs/libraries/matplotlib.md @@ -6,12 +6,16 @@ description: >- # :material-chart-line:{ .lg .middle } matplotlib library +
+ [matplotlib documentation :material-open-in-new:](https://matplotlib.org/stable/){ .md-button target="_blank" } matplotlib is an open-source project, funded by nonprofit [NumFOCUS](https://numfocus.org/). **matplotlib** (its plotting interface imported as `plt`) is Python's foundational library for creating charts — line plots, bar charts, scatter plots — directly from plain Python data. It's a third-party package, not part of the standard library, but it's a foundational Python plotting library that many other Python tools integrate with or build upon. Like [Pillow](pillow.md) and [OpenCV](opencv.md), matplotlib produces visual output — a chart shown in a window or saved to a file — which can't be shown inside this site's browser sandbox, so the examples below aren't runnable here. Copy them into a local `.py` file and run them with `python` to see the results. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/numpy.md b/docs/libraries/numpy.md index 12f5f54..a42f472 100644 --- a/docs/libraries/numpy.md +++ b/docs/libraries/numpy.md @@ -6,12 +6,16 @@ description: >- # :material-matrix:{ .lg .middle } NumPy library +
+ [NumPy documentation :material-open-in-new:](https://numpy.org/doc/stable/){ .md-button target="_blank" } NumPy is an open-source project, with fiscal sponsorship from the nonprofit [NumFOCUS](https://numfocus.org/). **NumPy** (imported as `np`) is a widely used library for fast numeric arrays — the foundation nearly every other data or scientific library in Python is built on. It's a third-party package, not part of the standard library. A NumPy `ndarray` looks similar to a `list`, but every element is the same type and math operations apply to the whole array at once, instead of one item at a time. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/opencv.md b/docs/libraries/opencv.md index e95ff06..01573db 100644 --- a/docs/libraries/opencv.md +++ b/docs/libraries/opencv.md @@ -6,12 +6,16 @@ description: >- # :material-face-recognition:{ .lg .middle } OpenCV library +
+ [OpenCV documentation :material-open-in-new:](https://docs.opencv.org/4.x/d6/d00/tutorial_py_root.html){ .md-button target="_blank" } OpenCV is stewarded by nonprofit [OpenCV.org](https://opencv.org/). **OpenCV** (imported as `cv2`) is a popular library for computer vision — real-time image and video analysis, rather than the straightforward photo editing [Pillow](pillow.md) is built for. It's a third-party package, originally written in C++ with a thin Python wrapper over it, which shows up in a couple of its API choices: images load as plain NumPy arrays instead of a dedicated `Image` class, and in **BGR** (blue-green-red) channel order rather than the RGB most other tools expect. Like Pillow and [Tkinter](tkinter.md), OpenCV produces visual, often interactive output — a window showing an image or a live camera feed — that can't run inside this site's browser sandbox, so the examples below aren't runnable here. Copy them into a local `.py` file alongside an image and run them with `python` to see the results. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/pandas.md b/docs/libraries/pandas.md index 6c08ddf..06d64eb 100644 --- a/docs/libraries/pandas.md +++ b/docs/libraries/pandas.md @@ -6,12 +6,16 @@ description: >- # :material-table:{ .lg .middle } pandas library +
+ [pandas documentation :material-open-in-new:](https://pandas.pydata.org/docs/){ .md-button target="_blank" } pandas is an open-source project, funded by nonprofit [NumFOCUS](https://numfocus.org/). **pandas** (imported as `pd`) is a widely used library for tabular data — rows and columns, like a spreadsheet, with tools for filtering, sorting, and summarizing built in. It's a third-party package, not part of the standard library, and is built on top of [NumPy](numpy.md). +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/pillow.md b/docs/libraries/pillow.md index 8487157..6170e96 100644 --- a/docs/libraries/pillow.md +++ b/docs/libraries/pillow.md @@ -6,12 +6,16 @@ description: >- # :material-image-outline:{ .lg .middle } Pillow library +
+ [Pillow documentation :material-open-in-new:](https://pillow.readthedocs.io/en/stable/){ .md-button target="_blank" } Pillow is an open-source project maintained by volunteer contributors. **Pillow** (imported as `PIL`) is a popular library for opening, editing, and saving image files — photos, screenshots, thumbnails, anything in a common format like JPEG or PNG. It's a third-party package, not part of the standard library, but it's the de facto standard for image work in Python. Like [Tkinter](tkinter.md), Pillow ultimately produces visual output — a saved or displayed image — which can't be shown inside this site's browser sandbox, so the examples below aren't runnable here. Copy them into a local `.py` file alongside an image and run them with `python` to see the results. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/pytest.md b/docs/libraries/pytest.md index 2227d8e..af6f4f4 100644 --- a/docs/libraries/pytest.md +++ b/docs/libraries/pytest.md @@ -6,12 +6,16 @@ description: >- # :material-test-tube:{ .lg .middle } pytest library +
+ [pytest documentation :material-open-in-new:](https://docs.pytest.org/en/stable/){ .md-button target="_blank" } pytest is an open-source project maintained by volunteer contributors. **pytest** is Python's most widely used testing framework — it finds test functions in a project, runs each one, and reports which passed or failed. It's a third-party package, not part of the standard library, but it's largely replaced the built-in `unittest` module for new projects because a test is just a function with a plain `assert` statement, instead of a class built on a special base and assert methods like `.assertEqual()`. Every example below actually runs in your browser: Pyodide gives each page its own in-memory filesystem, so writing a test file and pointing pytest at it works the same way it would on a real computer. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/random.md b/docs/libraries/random.md index 5c90ac8..380734b 100644 --- a/docs/libraries/random.md +++ b/docs/libraries/random.md @@ -4,10 +4,14 @@ description: Generating random numbers and making random selections in Python wi # :material-dice-multiple:{ .lg .middle } random library +
+ [random documentation :material-open-in-new:](https://docs.python.org/3/library/random.html){ .md-button target="_blank" } The **`random`** module generates pseudo-random numbers and makes random selections — rolling a dice, shuffling a deck, or picking a specimen to feature at random. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/re.md b/docs/libraries/re.md index c3b7885..b9b7e1b 100644 --- a/docs/libraries/re.md +++ b/docs/libraries/re.md @@ -6,10 +6,14 @@ description: >- # :material-regex:{ .lg .middle } re library +
+ [re documentation :material-open-in-new:](https://docs.python.org/3/library/re.html){ .md-button target="_blank" } The **`re`** module works with regular expressions — patterns that describe text to search for, extract, or replace, more flexible than plain string methods like `.find()` or `.replace()`. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/requests.md b/docs/libraries/requests.md index e55b735..68e6d9a 100644 --- a/docs/libraries/requests.md +++ b/docs/libraries/requests.md @@ -6,12 +6,16 @@ description: >- # :material-webhook:{ .lg .middle } requests library +
+ [requests documentation :material-open-in-new:](https://requests.readthedocs.io/en/latest/){ .md-button target="_blank" } requests is an open-source project maintained by volunteer contributors. **`requests`** is a library for fetching data over the internet — asking a website or API for information, the same way a browser does, but from inside a Python program. It's not part of the standard library, but it's the de facto standard for this in Python, favored over the built-in `urllib` for its much simpler syntax. Every example on this page makes a real network call, which this site's in-browser sandbox can't do — copy them into a local `.py` file and run them with `python` to see the results. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/time.md b/docs/libraries/time.md index 4e29a00..825a68b 100644 --- a/docs/libraries/time.md +++ b/docs/libraries/time.md @@ -6,6 +6,8 @@ description: >- # :material-clock-outline:{ .lg .middle } time library +
+ [time documentation :material-open-in-new:](https://docs.python.org/3/library/time.html){ .md-button target="_blank" } The **`time`** module reads the system clock, pauses a program for a set number of seconds, and measures how long a piece of code takes to run. @@ -17,6 +19,8 @@ The **`time`** module reads the system clock, pauses a program for a set number | Timezone support | Limited — relies on the system's local time. | Full — handles timezone-aware dates and conversions. | | Common uses |
  • Benchmarking how long code takes to run
  • Pausing a program with `sleep()`
|
  • Logging when something happened
  • Calculating an age or a deadline
  • Date arithmetic
| +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/tkinter.md b/docs/libraries/tkinter.md index 057aa3b..4e8155d 100644 --- a/docs/libraries/tkinter.md +++ b/docs/libraries/tkinter.md @@ -6,10 +6,14 @@ description: >- # :material-application-outline:{ .lg .middle } Tkinter library +
+ [Tkinter documentation :material-open-in-new:](https://docs.python.org/3/library/tkinter.html){ .md-button target="_blank" } **Tkinter** is Python's built-in toolkit for building desktop GUI applications — windows, buttons, text fields, and the rest of a traditional app interface, all driven from your Python variables, functions, and objects. A GUI needs a real window and display to run in, though, so unlike the rest of this field guide, the examples below aren't runnable in the browser — copy them into a local `.py` file to see them in action. +
+
## Setup { data-card-link="skip" } diff --git a/docs/libraries/turtle.md b/docs/libraries/turtle.md index fa6b504..249bf33 100644 --- a/docs/libraries/turtle.md +++ b/docs/libraries/turtle.md @@ -6,8 +6,12 @@ description: >- # :material-turtle:{ .lg .middle } Turtle library +
+ [Turtle documentation :material-open-in-new:](https://docs.python.org/3/library/turtle.html){ .md-button target="_blank" } +
+
## Concepts diff --git a/docs/loops.md b/docs/loops.md index c176064..43f8eda 100644 --- a/docs/loops.md +++ b/docs/loops.md @@ -6,6 +6,8 @@ description: >- # :material-repeat:{ .lg .middle } Loops +
+ A **loop** repeats a block of code multiple times.
@@ -44,6 +46,8 @@ A **loop** repeats a block of code multiple times.

FIG: choosing between a for loop and a while loop

+
+
## For loops diff --git a/docs/privacy.md b/docs/privacy.md index 57c7591..1d62008 100644 --- a/docs/privacy.md +++ b/docs/privacy.md @@ -4,10 +4,14 @@ description: How Python Field Guide uses Google Analytics and what data it colle # Privacy policy +
+ This site uses Google Analytics to understand how visitors use it — which pages are read, how people navigate between them, and roughly what devices/browsers they arrive on. That data helps decide what to improve or expand next. +
+
## What's collected diff --git a/docs/style.md b/docs/style.md index fd18aa0..ac6fd13 100644 --- a/docs/style.md +++ b/docs/style.md @@ -6,6 +6,8 @@ description: >- # :material-palette-outline:{ .lg .middle } Style +
+ Code that works isn't automatically code that's easy to read and maintain. - **Consistent:** following the same conventions reads the same, no matter who wrote it @@ -13,6 +15,8 @@ Code that works isn't automatically code that's easy to read and maintain. - **Easier to debug:** you know where to look when something breaks - **Effective collaboration:** when your code is **reviewed** so it can be **merged** in with everyone else's changes, consistent style means it's clearer what you actually changed, instead of needing to compare conflicting formatting choices +
+
## PEP 8 style guide diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index ea9c98a..1d8ac4e 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -211,66 +211,104 @@ html:focus-within::-webkit-scrollbar-thumb { } } -/* Decorative snake-scale header, slate (dark) scheme only. Layered on top of - .md-header's own background-color (the translucent --md-primary-fg-color - set above), so the blur/hairline border above still apply underneath. - - The first two radial-gradient layers are the scale rings: each is a - column of left-opening ring outlines (only the left-hand crescent of the - ring shows within each tile), and the second layer repeats the same rings - offset by half a tile in both axes — nesting a column of scales into the - gaps of the column to its right, the classic staggered fish-scale/shingle - arrangement, oriented to flow horizontally to match the header's shape. - - The third layer is a very slow, very low-contrast shimmer sitting behind - the scales — a linear-gradient through three near-black hues (indigo, - purple, green), animated via background-position so it drifts rather than - sitting static. Kept subtle deliberately: low opacity, and colors close in - value to --pt-bg, so it reads as a faint sheen rather than a visible band. */ +/* Decorative header art, slate (dark) scheme. Layered on top of .md-header's + own background-color (the translucent --md-primary-fg-color set above), so + the blur/hairline border above still apply underneath. + + header_dark.svg has no background rect of its own (transparent outside the + artwork), so .md-header's flat background-color shows through untouched + wherever the art doesn't cover — it reads as the exact same page + background, not a tinted or shimmered one. + + The shimmer — a slow, low-contrast linear-gradient through three + near-black hues (indigo, purple, green), animated via background-position + so it drifts rather than sitting static — lives on a ::before layered + above the art, clipped with `mask-image: url(header_dark.svg)` so it only + paints over the SVG's own opaque pixels. Because the mask and the artwork + share one file and the same size/position/repeat values, they can't drift + out of alignment the way two independently-authored layers could. The + pseudo-element sits at z-index: -1 within .md-header's own stacking + context (already established by its backdrop-filter above), so it paints + above .md-header's background but below the title/toggles/search. */ [data-md-color-scheme="slate"] .md-header { - background-image: - radial-gradient(circle at 100% 50%, transparent 14px, rgba(103, 58, 183, 0.2) 15px, rgba(63, 81, 181, 0.2) 16px, transparent 17px), - radial-gradient(circle at 100% 50%, transparent 14px, rgba(63, 81, 181, 0.2) 15px, rgba(103, 58, 183, 0.2) 16px, transparent 17px), - linear-gradient(120deg, - color-mix(in srgb, var(--pt-shimmer-indigo) 55%, transparent), - color-mix(in srgb, var(--pt-shimmer-purple) 55%, transparent), - color-mix(in srgb, var(--pt-shimmer-green) 55%, transparent), - color-mix(in srgb, var(--pt-shimmer-indigo) 55%, transparent)); - background-size: 28px 36px, 28px 36px, 320% 320%; - background-position: 0 0, 14px 18px, 0% 50%; -} - -/* Same decorative scale-ring + shimmer treatment, light (default) scheme. - Ring colors swap from dark mode's purple/indigo jewel tones to the site's - own gold/green palette (--pt-ref-keyword, --pt-accent), since purple reads - as an unrelated outlier against cream rather than a deliberate accent the - way it does against slate's near-black background. Shimmer hues likewise - swap to warm gold/sage/clay (--pt-shimmer-*) instead of indigo/purple/green - — colors close in value to --pt-bg so it stays a faint sheen, not a band. */ + background-image: url("../img/header_dark.svg"); + background-size: auto 100%; + background-position: left center; + background-repeat: repeat-x; +} + +[data-md-color-scheme="slate"] .md-header::before { + content: ""; + position: absolute; + inset: 0; + z-index: -1; + pointer-events: none; + background-image: linear-gradient(120deg, + color-mix(in srgb, var(--pt-shimmer-indigo) 55%, transparent), + color-mix(in srgb, var(--pt-shimmer-purple) 55%, transparent), + color-mix(in srgb, var(--pt-shimmer-green) 55%, transparent), + color-mix(in srgb, var(--pt-shimmer-indigo) 55%, transparent)); + background-size: 320% 320%; + background-position: 0% 50%; + -webkit-mask-image: url("../img/header_dark.svg"); + mask-image: url("../img/header_dark.svg"); + mask-mode: alpha; + -webkit-mask-size: auto 100%; + mask-size: auto 100%; + -webkit-mask-position: left center; + mask-position: left center; + -webkit-mask-repeat: repeat-x; + mask-repeat: repeat-x; +} + +/* Same treatment, light (default) scheme, over header_light.svg — a + separately pre-colored, background-stripped export rather than one shared + SVG recolored via CSS, so the artwork's two accent colors can't drift out + of alignment with each other. Shimmer hues swap to warm gold/sage/clay + (--pt-shimmer-*) instead of indigo/purple/green so the moving sheen reads + as this site's own palette rather than dark mode's jewel tones. */ [data-md-color-scheme="default"] .md-header { - background-image: - radial-gradient(circle at 100% 50%, transparent 14px, rgba(130, 94, 37, 0.07) 15px, rgba(8, 84, 42, 0.07) 16px, transparent 17px), - radial-gradient(circle at 100% 50%, transparent 14px, rgba(8, 84, 42, 0.07) 15px, rgba(130, 94, 37, 0.07) 16px, transparent 17px), - linear-gradient(120deg, - color-mix(in srgb, var(--pt-shimmer-gold) 18%, transparent), - color-mix(in srgb, var(--pt-shimmer-sage) 18%, transparent), - color-mix(in srgb, var(--pt-shimmer-clay) 18%, transparent), - color-mix(in srgb, var(--pt-shimmer-gold) 18%, transparent)); - background-size: 28px 36px, 28px 36px, 320% 320%; - background-position: 0 0, 14px 18px, 0% 50%; + background-image: url("../img/header_light.svg"); + background-size: auto 100%; + background-position: left center; + background-repeat: repeat-x; +} + +[data-md-color-scheme="default"] .md-header::before { + content: ""; + position: absolute; + inset: 0; + z-index: -1; + pointer-events: none; + background-image: linear-gradient(120deg, + color-mix(in srgb, var(--pt-shimmer-gold) 18%, transparent), + color-mix(in srgb, var(--pt-shimmer-sage) 18%, transparent), + color-mix(in srgb, var(--pt-shimmer-clay) 18%, transparent), + color-mix(in srgb, var(--pt-shimmer-gold) 18%, transparent)); + background-size: 320% 320%; + background-position: 0% 50%; + -webkit-mask-image: url("../img/header_light.svg"); + mask-image: url("../img/header_light.svg"); + mask-mode: alpha; + -webkit-mask-size: auto 100%; + mask-size: auto 100%; + -webkit-mask-position: left center; + mask-position: left center; + -webkit-mask-repeat: repeat-x; + mask-repeat: repeat-x; } @media (prefers-reduced-motion: no-preference) { - [data-md-color-scheme="slate"] .md-header, - [data-md-color-scheme="default"] .md-header { + [data-md-color-scheme="slate"] .md-header::before, + [data-md-color-scheme="default"] .md-header::before { animation: pt-header-shimmer 22s ease-in-out infinite; } } @keyframes pt-header-shimmer { - 0% { background-position: 0 0, 14px 18px, 0% 50%; } - 50% { background-position: 0 0, 14px 18px, 100% 50%; } - 100% { background-position: 0 0, 14px 18px, 0% 50%; } + 0% { background-position: 0% 50%; } + 50% { background-position: 100% 50%; } + 100% { background-position: 0% 50%; } } .md-header__button.md-logo img { @@ -810,6 +848,14 @@ input:checked + .md-consent__settings { border: 0.05rem solid currentColor; border-radius: 1rem; overflow: hidden; + /* The site's own background, not transparent — otherwise the inactive + option just shows whatever's behind the header (the translucent + --md-primary-fg-color, plus the header's own scale/shimmer pattern on + top), so the track read inconsistently depending on scroll position + and theme. A flat --pt-bg fill keeps the inactive side legible and + matches the highlight pill's own solid currentColor fill instead of + looking like a hole cut into the header. */ + background-color: var(--pt-bg); } .pt-simplify-highlight { @@ -973,6 +1019,20 @@ input:checked + .md-consent__settings { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-120q-150 0-255-105T120-480q0-150 105-255t255-105q8 0 17 .5t23 1.5q-36 32-56 79t-20 99q0 90 63 153t153 63q52 0 99-18.5t79-51.5q1 12 1.5 19.5t.5 14.5q0 150-105 255T480-120Zm0-60q109 0 190-67.5T771-406q-25 11-53.67 16.5Q688.67-384 660-384q-114.69 0-195.34-80.66Q384-545.31 384-660q0-24 5-51.5t18-62.5q-98 27-162.5 109.5T180-480q0 125 87.5 212.5T480-180Zm-4-297Z'/%3E%3C/svg%3E"); } +/* Same sun/moon icons, reusable on a real element (not a pseudo-element) — + used by the toast (docs/javascripts/essentials_toggle.js's showToast) + for the light/dark toggle's own "Lights on"/"Lights off" message, + keeping it visually consistent with .pt-theme-option's icon. */ +.pt-mode-icon[data-scheme="default"] { + -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M579-381q41-41 41-99t-41-99q-41-41-99-41t-99 41q-41 41-41 99t41 99q41 41 99 41t99-41Zm-240.5 42.5Q280-397 280-480t58.5-141.5Q397-680 480-680t141.5 58.5Q680-563 680-480t-58.5 141.5Q563-280 480-280t-141.5-58.5ZM200-450H40v-60h160v60Zm720 0H760v-60h160v60ZM450-760v-160h60v160h-60Zm0 720v-160h60v160h-60ZM262-658l-100-97 43-44 96 100-39 41Zm494 496-98-100 41-41 99 98-42 43Zm-99-537 98-99 44 42-99 98-43-41ZM162-205l99-98 42 42-98 99-43-43Zm318-275Z'/%3E%3C/svg%3E"); + mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M579-381q41-41 41-99t-41-99q-41-41-99-41t-99 41q-41 41-41 99t41 99q41 41 99 41t99-41Zm-240.5 42.5Q280-397 280-480t58.5-141.5Q397-680 480-680t141.5 58.5Q680-563 680-480t-58.5 141.5Q563-280 480-280t-141.5-58.5ZM200-450H40v-60h160v60Zm720 0H760v-60h160v60ZM450-760v-160h60v160h-60Zm0 720v-160h60v160h-60ZM262-658l-100-97 43-44 96 100-39 41Zm494 496-98-100 41-41 99 98-42 43Zm-99-537 98-99 44 42-99 98-43-41ZM162-205l99-98 42 42-98 99-43-43Zm318-275Z'/%3E%3C/svg%3E"); +} + +.pt-mode-icon[data-scheme="slate"] { + -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-120q-150 0-255-105T120-480q0-150 105-255t255-105q8 0 17 .5t23 1.5q-36 32-56 79t-20 99q0 90 63 153t153 63q52 0 99-18.5t79-51.5q1 12 1.5 19.5t.5 14.5q0 150-105 255T480-120Zm0-60q109 0 190-67.5T771-406q-25 11-53.67 16.5Q688.67-384 660-384q-114.69 0-195.34-80.66Q384-545.31 384-660q0-24 5-51.5t18-62.5q-98 27-162.5 109.5T180-480q0 125 87.5 212.5T480-180Zm-4-297Z'/%3E%3C/svg%3E"); + mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-120q-150 0-255-105T120-480q0-150 105-255t255-105q8 0 17 .5t23 1.5q-36 32-56 79t-20 99q0 90 63 153t153 63q52 0 99-18.5t79-51.5q1 12 1.5 19.5t.5 14.5q0 150-105 255T480-120Zm0-60q109 0 190-67.5T771-406q-25 11-53.67 16.5Q688.67-384 660-384q-114.69 0-195.34-80.66Q384-545.31 384-660q0-24 5-51.5t18-62.5q-98 27-162.5 109.5T180-480q0 125 87.5 212.5T480-180Zm-4-297Z'/%3E%3C/svg%3E"); +} + /* Disappearing confirmation toast for the Essentials/Advanced toggle (docs/javascripts/essentials_toggle.js's showToast). Sits just below the header — right where the toggle that triggered it lives — rather than @@ -999,6 +1059,11 @@ input:checked + .md-consent__settings { text-align: center; box-shadow: 0 0.2rem 0.6rem rgba(0, 0, 0, 0.25); opacity: 0; + /* none while hidden, so an invisible toast (opacity alone doesn't take + it out of hit-testing) doesn't block clicks on whatever's under where + it will appear; .pt-toast--visible switches it back to auto so a + click on the visible toast is absorbed instead of passing through to + the page content behind it. */ pointer-events: none; /* Fade only — no slide/transform. The fade-out itself is slow and gentle; showToast() in essentials_toggle.js keeps the fully-visible @@ -1009,6 +1074,7 @@ input:checked + .md-consent__settings { .pt-toast--visible { opacity: 1; + pointer-events: auto; /* Fading in can be quick; only the fade-out (the base .pt-toast rule above, used once this class is removed again) is slow. */ transition: opacity 0.15s ease; @@ -1020,6 +1086,14 @@ input:checked + .md-consent__settings { justify-content: center; gap: 0.25rem; font-weight: 700; +} + +/* Only add space below the title when there's actually a body line under + it (the Essentials/Advanced toast has one; the light/dark toast's title + is self-explanatory and passes no body — see showToast() in + essentials_toggle.js) — otherwise this margin just reads as extra + padding at the bottom of a one-line toast. */ +.pt-toast__title:not(:last-child) { margin-bottom: 0.2rem; } @@ -1176,9 +1250,17 @@ input:checked + .md-consent__settings { height: 1.05rem; } -.md-typeset .grid.cards a.pt-lib-badge--builtin, -.md-typeset .grid.cards a.pt-lib-badge--third-party { - color: var(--pt-desc-blue); +/* Built-in/third-party corner badge: halfway between the card's own + background color and the muted category-label color, in both light and + dark mode. */ +[data-md-color-scheme="default"] .md-typeset .grid.cards a.pt-lib-badge--builtin, +[data-md-color-scheme="default"] .md-typeset .grid.cards a.pt-lib-badge--third-party { + color: color-mix(in srgb, var(--pt-panel), color-mix(in srgb, var(--pt-ink) 80%, white)); +} + +[data-md-color-scheme="slate"] .md-typeset .grid.cards a.pt-lib-badge--builtin, +[data-md-color-scheme="slate"] .md-typeset .grid.cards a.pt-lib-badge--third-party { + color: color-mix(in srgb, color-mix(in srgb, var(--pt-panel) 92%, var(--pt-ink)), color-mix(in srgb, var(--pt-ink) 80%, black)); } /* Homepage cards, dark mode only: green is reserved for the smaller non-bold diff --git a/docs/types.md b/docs/types.md index f376d0b..7edfdd3 100644 --- a/docs/types.md +++ b/docs/types.md @@ -6,6 +6,8 @@ description: >- # :material-shape-outline:{ .lg .middle } Basic data types +
+ Every value in Python has a **type**, which determines what operations it supports and how it behaves. A basic data type holds a single value, as opposed to a [collection](collections.md) data type, which groups multiple values together. The basic types covered here — `int`, `float`, `str`, `bool`, and `None` — are immutable. @@ -37,6 +39,8 @@ A basic data type holds a single value, as opposed to a [collection](collections isinstance(weight, str) # False ``` +
+
## Integers