Skip to content

Commit 437ec88

Browse files
committed
Sample code - Python 3.12 preview f-strings
1 parent 3f2ab7e commit 437ec88

5 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Python 3.12 Preview: More Intuitive and Consistent F-Strings
2+
3+
This folder provides the code examples for the Real Python tutorial [Python 3.12 Preview: More Intuitive and Consistent F-Strings](https://realpython.com/python312-f-strings/).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
words = ["Hello", "World!", "I", "am", "a", "Pythonista!"]
2+
3+
print("One Word by Line:\n" + f"{'\n'.join(words)}")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
employee = {
2+
"name": "John Doe",
3+
"age": 35,
4+
"job": "Python Developer",
5+
}
6+
7+
f"""Storing employee's data: {
8+
employee['name'].upper() # Always uppercase name before storing
9+
}"""
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
f"{
2+
f"{
3+
f"{
4+
f"{
5+
f"{
6+
f"Deeply nested f-string!"
7+
}"
8+
}"
9+
}"
10+
}"
11+
}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
employee = {
2+
"name": "John Doe",
3+
"age": 35,
4+
"job": "Python Developer",
5+
}
6+
7+
f"Employee: {employee["name"]}"

0 commit comments

Comments
 (0)