[Python-ideas] One way to do format and print (was: Desperate need for enhanced print function)

Sven R. Kunze srkunze at mail.de
Mon Sep 7 07:46:44 CEST 2015


On 07.09.2015 01:48, Nick Coghlan wrote:
> As such, it currently appears likely that Python 3.6 will allow you and
> your peers to write output messages like this:
>
>      print(f"Hello, I am {b}. My favorite number is {a}.")
>
> as a simpler alternative to the current options:
>
>      print("Hello, I am ", b, ". My favorite number is ", a, ".", sep="")
>      print("Hello, I am " + b + ". My favorite number is " + str(a) + ".")
>      print("Hello, I am {}. My favorite number is {}.".format(b, a))
>      print("Hello, I am {b}. My favorite number is {a}.".format_map(locals()))
>      print("Hello, I am %s. My favorite number is %s." % (b, a))

Wow, that is awesome and awkward at the same time.

Shouldn't Python 3.7 deprecate at least some of them? (Just looking at 
the Zen of Python and https://xkcd.com/927/ )

Best,
Sven


More information about the Python-ideas mailing list