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
83
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
もう僕は OpenAPI を書きたくない
sgash708
6
1.9k
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
1.2k
From the Wild into the Clouds - Laravel Meetup Talk
neverything
0
170
Jakarta EE meets AI
ivargrimstad
0
550
PHPのバージョンアップ時にも役立ったAST
matsuo_atsushi
0
230
kintone開発を効率化するためにチームで試した施策とその結果を大放出!
oguemon
0
290
1年目の私に伝えたい!テストコードを怖がらなくなるためのヒント/Tips for not being afraid of test code
push_gawa
1
640
15分で学ぶDuckDBの可愛い使い方 DuckDBの最近の更新
notrogue
3
800
新宿駅構内を三人称視点で探索してみる
satoshi7190
2
120
生成AIで加速するテスト実装 - ロリポップ for Gamersの事例と 生成AIエディタの活用
kinosuke01
0
130
AWS Step Functions は CDK で書こう!
konokenj
4
790
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
1k
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
13
1k
Producing Creativity
orderedlist
PRO
344
40k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
21
2.5k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.3k
Embracing the Ebb and Flow
colly
84
4.6k
The World Runs on Bad Software
bkeepers
PRO
67
11k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Product Roadmaps are Hard
iamctodd
PRO
51
11k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
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