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
26
Introduction to PyCon US 2024
mariatta
0
150
PEP Talk
mariatta
0
540
PyCon US 2023: Sunday Morning Welcome Message
mariatta
0
57
PyConUS2023_Closing.pdf
mariatta
0
72
PyCon US 2023: Saturday Morning Welcome Message
mariatta
0
55
Welcome to PyCon US 2023
mariatta
0
47
PyCon US 2023 Lightning Talk
mariatta
0
160
Contributing to Python
mariatta
0
260
Other Decks in Programming
See All in Programming
Lookerは可視化だけじゃない。UIコンポーネントもあるんだ!
ymd65536
1
120
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
270
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
6
1.4k
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
750
Запуск 1С:УХ в крупном энтерпрайзе: мечта и реальность ПМа
lamodatech
0
920
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
410
快速入門可觀測性
blueswen
0
490
Androidアプリの One Experience リリース
nein37
0
980
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
26
3.2k
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
910
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
1.3k
HTML/CSS超絶浅い説明
yuki0329
0
180
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
521
39k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
The Language of Interfaces
destraynor
155
24k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Designing Experiences People Love
moore
139
23k
How to Ace a Technical Interview
jacobian
276
23k
Embracing the Ebb and Flow
colly
84
4.5k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Automating Front-end Workflow
addyosmani
1366
200k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
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