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
380
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
33
Introduction to PyCon US 2024
mariatta
0
160
PEP Talk
mariatta
0
560
PyCon US 2023: Sunday Morning Welcome Message
mariatta
0
62
PyConUS2023_Closing.pdf
mariatta
0
82
PyCon US 2023: Saturday Morning Welcome Message
mariatta
0
63
Welcome to PyCon US 2023
mariatta
0
53
PyCon US 2023 Lightning Talk
mariatta
0
170
Contributing to Python
mariatta
0
280
Other Decks in Programming
See All in Programming
SwiftUI Viewの責務分離
elmetal
PRO
2
270
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
920
Honoをフロントエンドで使う 3つのやり方
yusukebe
7
3.5k
ナレッジイネイブリングにAIを活用してみる ゆるSRE勉強会 #9
nealle
0
160
Domain-Driven Design (Tutorial)
hschwentner
13
22k
1年目の私に伝えたい!テストコードを怖がらなくなるためのヒント/Tips for not being afraid of test code
push_gawa
1
610
DRFを少しずつ オニオンアーキテクチャに寄せていく DjangoCongress JP 2025
nealle
2
270
PHPカンファレンス名古屋2025 タスク分解の試行錯誤〜レビュー負荷を下げるために〜
soichi
1
680
Learning Kotlin with detekt
inouehi
1
140
Jakarta EE meets AI
ivargrimstad
0
390
color-scheme: light dark; を完全に理解する
uhyo
7
490
React 19アップデートのために必要なこと
uhyo
8
1.5k
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Adopting Sorbet at Scale
ufuk
74
9.2k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
Mobile First: as difficult as doing things right
swwweet
223
9.4k
A Philosophy of Restraint
colly
203
16k
Site-Speed That Sticks
csswizardry
4
410
The Cost Of JavaScript in 2023
addyosmani
47
7.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
10
510
It's Worth the Effort
3n
184
28k
A Modern Web Designer's Workflow
chriscoyier
693
190k
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