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
360
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
22
Introduction to PyCon US 2024
mariatta
0
140
PEP Talk
mariatta
0
520
PyCon US 2023: Sunday Morning Welcome Message
mariatta
0
55
PyConUS2023_Closing.pdf
mariatta
0
67
PyCon US 2023: Saturday Morning Welcome Message
mariatta
0
48
Welcome to PyCon US 2023
mariatta
0
44
PyCon US 2023 Lightning Talk
mariatta
0
150
Contributing to Python
mariatta
0
250
Other Decks in Programming
See All in Programming
イベント駆動で成長して委員会
happymana
1
320
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
290
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
Macとオーディオ再生 2024/11/02
yusukeito
0
370
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
110
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
120
距離関数を極める! / SESSIONS 2024
gam0022
0
280
Click-free releases & the making of a CLI app
oheyadam
2
120
Featured
See All Featured
Being A Developer After 40
akosma
86
590k
BBQ
matthewcrist
85
9.3k
Facilitating Awesome Meetings
lara
50
6.1k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Adopting Sorbet at Scale
ufuk
73
9.1k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Happy Clients
brianwarren
98
6.7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
880
How GitHub (no longer) Works
holman
310
140k
Documentation Writing (for coders)
carmenintech
65
4.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