Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
f-strings
Search
Mariatta
January 22, 2018
Programming
440
0
Share
f-strings
Lightning talk about f-strings. Presented at PyCascades 2018 in Vancouver.
Mariatta
January 22, 2018
More Decks by Mariatta
See All by Mariatta
There's an API for That!
mariatta
0
59
Introduction to PyCon US 2024
mariatta
0
270
PEP Talk
mariatta
0
710
PyCon US 2023: Sunday Morning Welcome Message
mariatta
0
110
PyConUS2023_Closing.pdf
mariatta
0
140
PyCon US 2023: Saturday Morning Welcome Message
mariatta
0
110
Welcome to PyCon US 2023
mariatta
0
110
PyCon US 2023 Lightning Talk
mariatta
0
240
Contributing to Python
mariatta
0
370
Other Decks in Programming
See All in Programming
実用!Hono RPC2026
yodaka
2
290
AIと共に生きる技術選定 2026
sgash708
0
120
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
460
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
160
書き換えて学ぶTemporal #fukts
pirosikick
2
330
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
730
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
Running Swift without an OS
kishikawakatsumi
0
880
いつか誰かが、と思っていた フロントエンド刷新5年間の実践知
kiichisugihara
1
250
JOAI2026 1st solution - heron0519 -
heron0519
0
170
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
270
Programming with a DJ Controller — not vibe coding
m_seki
3
750
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
55
8.1k
A Tale of Four Properties
chriscoyier
163
24k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Test your architecture with Archunit
thirion
1
2.2k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Agile that works and the tools we love
rasmusluckow
331
21k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
220
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
110
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
510
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
680
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
F-strings @mariatta
F-strings?
the new way to format strings
starting in Python 3.6
How?
How? "Hello, %s. You’re %s." % (name, age)
How? "Hello, {name}. You’re {age}.".format(name=name, age=age) "Hello, %s. You’re %s."
% (name, age)
How? "Hello, {name}. You’re {age}.".format(name=name, age=age) f"Hello, {name}. You’re {age}."
"Hello, %s. You’re %s." % (name, age)
Alternate usage
Alternate usage f"Hello, {name}. You’re {age}."
Alternate usage F"Hello, {name}. You’re {age}." f"Hello, {name}. You’re {age}."
Call a function >>> def to_uppercase(input): ... return input.upper() ...
>>> name = “bart simpson” >>> print(f"Hi {to_uppercase(name)}!") Hi BART SIMPSON!
Format specifiers >>> pycascades = datetime(year=2018, month=1, day=22) >>> print(f"{pycascades:%b
%d, %Y}") Jan 22, 2018
F-strings
Faster than str.format
Python 3.6
Free download www.python.org
Build from source https://docs.python.org/3.6/using/unix.html
Change your OS consider: MacOS X, Windows 10, fedora 26,
ubuntu 17.10
None