Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
kstrauser
46 days ago
|
parent
|
context
|
favorite
| on:
Python string literals are kinda funny
If age is a number, that won’t work.
layer8
46 days ago
[–]
Admittedly I’m not so familiar with Python; it does work in Java. In that case, introducing a less hazardous string concatenation operator would seem more universally useful.
kstrauser
46 days ago
|
parent
[–]
In Python, that less hazardous string concatenation operator is an f-string.
layer8
46 days ago
|
root
|
parent
[–]
I’m assuming you can only use it with string literals, hence it is less universally useful.
TZubiri
46 days ago
|
root
|
parent
[–]
Nope, you can put expressions in them:
f'{a} = {functionThatReturnsAButHasSideEffects()}'
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: