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
29
Introduction to PyCon US 2024
mariatta
0
150
PEP Talk
mariatta
0
550
PyCon US 2023: Sunday Morning Welcome Message
mariatta
0
59
PyConUS2023_Closing.pdf
mariatta
0
76
PyCon US 2023: Saturday Morning Welcome Message
mariatta
0
57
Welcome to PyCon US 2023
mariatta
0
50
PyCon US 2023 Lightning Talk
mariatta
0
160
Contributing to Python
mariatta
0
270
Other Decks in Programming
See All in Programming
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
2.3k
AWSマネコンに複数のアカウントで入れるようになりました
yuhta28
2
150
時計仕掛けのCompose
mkeeda
1
190
Linux && Docker 研修/Linux && Docker training
forrep
22
4k
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
3
1k
AHC041解説
terryu16
0
540
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
4
610
振り返れば奴(Cline)がいる
keiyagi
0
130
Lookerは可視化だけじゃない。UIコンポーネントもあるんだ!
ymd65536
1
140
DMMオンラインサロンアプリのSwift化
hayatan
0
270
ペアーズでの、Langfuseを中心とした評価ドリブンなリリースサイクルのご紹介
fukubaka0825
1
200
自分ひとりから始められる生産性向上の取り組み #でぃーぷらすオオサカ
irof
8
2.1k
Featured
See All Featured
Six Lessons from altMBA
skipperchong
27
3.6k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Embracing the Ebb and Flow
colly
84
4.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
3k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
Raft: Consensus for Rubyists
vanstee
137
6.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
192
16k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.4k
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