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
300
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
7
Introduction to PyCon US 2024
mariatta
0
68
PEP Talk
mariatta
0
400
PyCon US 2023: Sunday Morning Welcome Message
mariatta
0
46
PyConUS2023_Closing.pdf
mariatta
0
52
PyCon US 2023: Saturday Morning Welcome Message
mariatta
0
42
Welcome to PyCon US 2023
mariatta
0
36
PyCon US 2023 Lightning Talk
mariatta
0
110
Contributing to Python
mariatta
0
220
Other Decks in Programming
See All in Programming
DocC Tutorial と TCA におけるテスト機能の紹介
kalupas226
1
330
クソコード動画『カプセル化 Mk-II』 で考える 上手くカプセル化できない理由 / encapsulation2
minodriven
11
8k
OpenTelemetry のサービスという概念について
azukiazusa1
1
410
htmx is fun!
codehex
2
190
チームでモデリングを育てるうえで 考えたこと・気づいたこと / Cultivating Modeling in Teams: Thoughts and Insights
mackey0225
5
2.4k
WinUI 3デモ - "CommunityToolkit.Mvvm"NuGetパッケージ編
andrewkeepcoding
0
140
デザインシステムで Tailwind CSSとCSS in JSに分散投資をしたら良かった話
fsubal
14
3.5k
document.write再考
brn
5
2.5k
決断するための勇気、そのためのBacklog / Courage to make decisions, Backlog for that.
seike460
PRO
4
1.9k
実践!RDRAを活用した既存システムの仕様変更 / Specification Changes in Existing Systems Utilizing RDRA
imamotohikaru
0
2.7k
LPIXEL×CADDi_kaerururu
kaerururu
3
300
AppDeveloperCon 2024 EU: Building polyglot developer experiences in 2024
salaboy
0
380
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
153
14k
Optimizing for Happiness
mojombo
369
69k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
11
1.4k
Pencils Down: Stop Designing & Start Developing
hursman
115
11k
The Illustrated Children's Guide to Kubernetes
chrisshort
28
46k
Building Adaptive Systems
keathley
29
1.8k
Faster Mobile Websites
deanohume
296
30k
In The Pink: A Labor of Love
frogandcode
137
21k
Happy Clients
brianwarren
91
6.3k
Raft: Consensus for Rubyists
vanstee
130
6.2k
Designing Experiences People Love
moore
135
23k
Navigating Team Friction
lara
177
13k
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