Skip to content

Commit 2b951d8

Browse files
committed
Move the sample code to python-312/ and update the README.md
1 parent c89f205 commit 2b951d8

6 files changed

Lines changed: 19 additions & 3 deletions

File tree

python-312/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ You can learn more about Python 3.12's new features in the following Real Python
1414

1515
- [Python 3.12 Preview: Ever Better Error Messages](https://realpython.com/python312-error-messages/)
1616
- [Python 3.12 Preview: Support For the Linux `perf` Profiler](https://realpython.com/python312-perf-profiler/)
17+
- [Python 3.12 Preview: More Intuitive and Consistent F-Strings](https://realpython.com/python312-f-strings/)
1718

1819
You'll find examples from all these tutorials in this repository.
1920

@@ -117,6 +118,24 @@ $ cat traces_censored.txt | flamegraph.pl --minwidth 10 > flamegraph.svg
117118

118119
See [Support For the Linux `perf` Profiler in Python 3.12](https://realpython.com/python312-perf-profiler/) for more information.
119120

121+
### New F-String Implementation and Syntax Formalization
122+
123+
Once you have 3.12 installed, open any file from the `f-string/` folder. Uncomment the code as needed. [Run the scripts](https://realpython.com/run-python-scripts/) from your command line or execute the code directly in a [REPL](https://realpython.com/python-repl/) session. You'll see the new f-string implementation in action.
124+
125+
For example, go ahead and run the following command:
126+
127+
```console
128+
$ python backslaches.py
129+
Hello
130+
World!
131+
I
132+
am
133+
a
134+
Pythonista!
135+
```
136+
137+
This example shows how the new implementation of f-strings allows you to include backslashes in embedded expressions. This was a limitation of f-strings till Python 3.11.
138+
120139
## Authors
121140

122141
- **Martin Breuss**, E-mail: [martin@realpython.com](martin@realpython.com)

python312-preview-f-string/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)