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
410
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
38
Introduction to PyCon US 2024
mariatta
0
200
PEP Talk
mariatta
0
590
PyCon US 2023: Sunday Morning Welcome Message
mariatta
0
76
PyConUS2023_Closing.pdf
mariatta
0
96
PyCon US 2023: Saturday Morning Welcome Message
mariatta
0
76
Welcome to PyCon US 2023
mariatta
0
60
PyCon US 2023 Lightning Talk
mariatta
0
190
Contributing to Python
mariatta
0
310
Other Decks in Programming
See All in Programming
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
230
つよそうにふるまい、つよい成果を出すのなら、つよいのかもしれない
irof
1
300
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
340
C++20 射影変換
faithandbrave
0
530
Result型で“失敗”を型にするPHPコードの書き方
kajitack
4
310
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.3k
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
100
Kotlin エンジニアへ送る:Swift 案件に参加させられる日に備えて~似てるけど色々違う Swift の仕様 / from Kotlin to Swift
lovee
1
250
Gleamという選択肢
comamoca
6
760
FormFlow - Build Stunning Multistep Forms
yceruto
1
190
技術同人誌をMCP Serverにしてみた
74th
0
290
Effect の双対、Coeffect
yukikurage
5
1.5k
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
For a Future-Friendly Web
brad_frost
179
9.8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
Practical Orchestrator
shlominoach
188
11k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
930
Side Projects
sachag
455
42k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
A better future with KSS
kneath
239
17k
Speed Design
sergeychernyshev
32
1k
The World Runs on Bad Software
bkeepers
PRO
69
11k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
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