Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When not to use f-strings?
#5
(Sep-16-2019, 06:09 AM)buran Wrote: just to mention that if there is need for escaping within placeholder than it's a case of having expression IN the placeholder. In this case it would be better and more readable to have the expression prepared and assigned to a variable beforehand and use that variable in the f-string

To showcase buran's suggestion:

>>> newline = '\n'                                                        
>>> first = 'first'                                                       
>>> second = 'second'  
>>> print(f'{first}{newline}{second}')
first
second
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
When not to use f-strings? - by newbieAuggie2019 - Sep-16-2019, 02:46 AM
RE: When not to use f-strings? - by Gribouillis - Sep-16-2019, 04:54 AM
RE: When not to use f-strings? - by perfringo - Sep-16-2019, 05:56 AM
RE: When not to use f-strings? - by buran - Sep-16-2019, 06:09 AM
RE: When not to use f-strings? - by perfringo - Sep-16-2019, 06:20 AM
RE: When not to use f-strings? - by snippsat - Sep-16-2019, 08:54 AM
RE: When not to use f-strings? - by DeaD_EyE - Sep-16-2019, 08:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 837 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,834 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Finding multiple strings between the two same strings Slither 1 2,566 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  lists, strings, and byte strings Skaperen 2 4,281 Mar-02-2018, 02:12 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020