Add source examples for Python 3.10 and 3.9 with updated syntax (#842)

Co-authored-by: Esteban Maya Cadavid <emayacadavid9@gmail.com>
This commit is contained in:
Sebastián Ramírez
2024-03-21 17:49:38 -05:00
committed by GitHub
parent 4c3f242ae2
commit 9141c8a920
39 changed files with 7456 additions and 25 deletions

View File

@@ -39,10 +39,22 @@ We will continue with the code we used to create some heroes, and we'll update t
/// details | 👀 Full file preview
//// tab | Python 3.10+
```Python
{!./docs_src/tutorial/connect/insert/tutorial001_py310.py!}
```
////
//// tab | Python 3.7+
```Python
{!./docs_src/tutorial/connect/insert/tutorial001.py!}
```
////
///
## Assign a Team to a Hero
@@ -51,6 +63,24 @@ Let's say that **Tommy Sharp** uses his "rich uncle" charms to recruit **Spider-
Doing it is just like updating any other field:
//// tab | Python 3.10+
```Python hl_lines="8"
# Code above omitted 👆
{!./docs_src/tutorial/connect/update/tutorial001_py310.py[ln:29-30]!}
# Previous code here omitted 👈
{!./docs_src/tutorial/connect/update/tutorial001_py310.py[ln:60-64]!}
# Code below omitted 👇
```
////
//// tab | Python 3.7+
```Python hl_lines="8"
# Code above omitted 👆
@@ -63,12 +93,26 @@ Doing it is just like updating any other field:
# Code below omitted 👇
```
////
/// details | 👀 Full file preview
//// tab | Python 3.10+
```Python
{!./docs_src/tutorial/connect/update/tutorial001_py310.py!}
```
////
//// tab | Python 3.7+
```Python
{!./docs_src/tutorial/connect/update/tutorial001.py!}
```
////
///
We can simply **assign** a value to that field attribute `team_id`, then `add()` the hero to the session, and then `commit()`.