use pep723 to config pyscript
This commit is contained in:
parent
7e8ee9d17e
commit
25cb9c6403
6 changed files with 149 additions and 54 deletions
|
|
@ -74,35 +74,46 @@
|
|||
|
||||
#lorem(400)
|
||||
|
||||
#pyscript[
|
||||
```python
|
||||
for i in range(1, 16):
|
||||
if i % 3 == 0 and i % 5 == 0:
|
||||
print("plopliplop")
|
||||
elif i % 3 == 0:
|
||||
print("plop")
|
||||
elif i % 5 == 0:
|
||||
print("plip")
|
||||
else:
|
||||
print(i)
|
||||
```
|
||||
]
|
||||
#pyscript(repl: true)[
|
||||
```python
|
||||
ret = []
|
||||
for i in range(16, 31):
|
||||
if i % 3 == 0 and i % 5 == 0:
|
||||
ret.append("plopliplop")
|
||||
elif i % 3 == 0:
|
||||
ret.append("plop")
|
||||
elif i % 5 == 0:
|
||||
ret.append("plip")
|
||||
else:
|
||||
ret.append(i)
|
||||
# >>> print(ret)
|
||||
# [16, 17, 'plop', 19, 'plip', 'plop', 22, 23, 'plop', 'plip', 26, 'plop', 28, 29, 'plopliplop']
|
||||
```
|
||||
]
|
||||
```python
|
||||
# /// script
|
||||
# [tool.pyscript]
|
||||
# ///
|
||||
n = ""
|
||||
while not n.isnumeric():
|
||||
n = input("enter a valid number: ")
|
||||
|
||||
for i in range(1, int(n) + 1):
|
||||
if i % 3 == 0 and i % 5 == 0:
|
||||
print("plopliplop")
|
||||
elif i % 3 == 0:
|
||||
print("plop")
|
||||
elif i % 5 == 0:
|
||||
print("plip")
|
||||
else:
|
||||
print(i)
|
||||
```
|
||||
```python
|
||||
# /// script
|
||||
# # requires-python = ">=3.11" # not supported yet
|
||||
# dependencies = [
|
||||
# "rich",
|
||||
# ]
|
||||
#
|
||||
# [tool.pyscript]
|
||||
# repl = true
|
||||
# [tool.pyscript.files]
|
||||
# "https://peps.python.org/api/peps.json" = "./peps.json"
|
||||
# ///
|
||||
|
||||
import json
|
||||
from rich.pretty import pprint
|
||||
|
||||
with open("./peps.json") as fd:
|
||||
data = json.load(fd)
|
||||
pprint([(k, v["title"]) for k, v in data.items()][:10])
|
||||
# >>> print(data["723"]["title"])
|
||||
# Inline script metadata
|
||||
```
|
||||
|
||||
#summ.card
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue