Python Forum
instructing f-string over format()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
instructing f-string over format()
#9
If you do only simple variable substitution, you can also do it with .format(**locals()), for example
>>> a = 4
>>> b = 'foo'
>>> c = 'Guido'
>>> "The longest {b} has length {a}.".format(**locals())
'The longest foo has length 4.'
Reply


Messages In This Thread
instructing f-string over format() - by metulburr - Jul-13-2019, 12:27 AM
RE: instructing f-string over format() - by Gribouillis - Jul-13-2019, 11:29 PM

Forum Jump:

User Panel Messages

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