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
0
370
f-strings
Lightning talk about f-strings. Presented at PyCascades 2018 in Vancouver.
Mariatta
January 22, 2018
Tweet
Share
More Decks by Mariatta
See All by Mariatta
There's an API for That!
mariatta
0
24
Introduction to PyCon US 2024
mariatta
0
150
PEP Talk
mariatta
0
540
PyCon US 2023: Sunday Morning Welcome Message
mariatta
0
56
PyConUS2023_Closing.pdf
mariatta
0
71
PyCon US 2023: Saturday Morning Welcome Message
mariatta
0
53
Welcome to PyCon US 2023
mariatta
0
46
PyCon US 2023 Lightning Talk
mariatta
0
150
Contributing to Python
mariatta
0
260
Other Decks in Programming
See All in Programming
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
140
EC2からECSへ 念願のコンテナ移行と巨大レガシーPHPアプリケーションの再構築
sumiyae
2
440
Online-Dokumentation, die hilft: Strukturen, Prozesse, Tools
ahus1
0
100
命名をリントする
chiroruxx
1
450
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
730
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
130
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
510
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
450
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
290
Go の GC の不得意な部分を克服したい
taiyow
3
840
useSyncExternalStoreを使いまくる
ssssota
6
1.4k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
328
21k
How to Ace a Technical Interview
jacobian
276
23k
Navigating Team Friction
lara
183
15k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The Cult of Friendly URLs
andyhume
78
6.1k
Fireside Chat
paigeccino
34
3.1k
Building an army of robots
kneath
302
44k
Designing for Performance
lara
604
68k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
4 Signs Your Business is Dying
shpigford
182
21k
Optimising Largest Contentful Paint
csswizardry
33
3k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
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