Skip to content

Commit a261ebc

Browse files
authored
Merge branch 'master' into gemini-cli
2 parents fcea3ae + f5890ea commit a261ebc

File tree

12 files changed

+76
-3
lines changed

12 files changed

+76
-3
lines changed

how-to-indent-in-python/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# How to Properly Indent Python Code
2+
3+
This folder contains sample code for the Real Python tutorial [How to Properly Indent Python Code](https://realpython.com/how-to-indent-in-python/).
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
long_list_of_names = [
2+
"Amy",
3+
"Brian",
4+
"Carol",
5+
"Dennis",
6+
"Emma",
7+
"Frank",
8+
"Georgia",
9+
"Herbert",
10+
"Isabelle",
11+
"Joshua",
12+
"Kimberly",
13+
"Laurence",
14+
"Megan",
15+
"Nicolas",
16+
"Ophelia",
17+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
lucky_number = 7
2+
for number in range(10):
3+
if number == lucky_number:
4+
print("Found the lucky number!")
5+
else:
6+
print(f"{number} is not my lucky number.")
7+
8+
print("Done.")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ruff: noqa
2+
def add(a, b):
3+
answer = a + b
4+
5+
return answer
6+
7+
def sub (c ,
8+
d):
9+
10+
answer = c -d
11+
12+
return answer

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ line-length = 79
44
exclude = [
55
".devcontainers",
66
".github",
7-
"migrations"
7+
"migrations",
8+
"how-to-indent-in-python/sample_code.py"
89
]
910

1011
[tool.ruff.lint]

python-bytes-to-strings/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# How to Convert Bytes to Strings in Python
2+
3+
The materials contained in this folder are designed to complement the Real Python tutorial [How to Convert Bytes to Strings in Python](https://realpython.com/convert-python-bytes-to-strings/).
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from urllib.request import urlopen
2+
3+
url = "https://example.com/"
4+
5+
with urlopen(url) as response:
6+
raw_bytes: bytes = response.read()
7+
8+
print("Bytes:", raw_bytes[:100])
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from urllib.request import urlopen
2+
3+
url = "https://example.com/"
4+
5+
with urlopen(url) as response:
6+
raw_bytes: bytes = response.read()
7+
8+
print("Bytes:", raw_bytes[:100])
9+
print("String:", raw_bytes[:100].decode())
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
encoded_text = b"d\xe9j\xe0 vu"
2+
3+
print(f"{encoded_text.decode("utf-8", errors="ignore") = }")
4+
print(f"{encoded_text.decode("utf-8", errors="replace") = }")
5+
print(f"{encoded_text.decode("utf-8", errors="backslashreplace") = }")
6+
print(f"{encoded_text.decode('utf-8')}")

python-bytes-to-strings/mixup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
raw_bytes = b"These are some interesting bytes"
2+
raw_bytes.replace("y", "o")

0 commit comments

Comments
 (0)