On 05/07/2021 09:18, Olaf Hering wrote:
> Am Fri, 2 Jul 2021 17:39:54 +0100
> schrieb Andrew Cooper <[email protected]>:
>
>> However, the % (phys, ) with the trailing comma is deliberate to work
>> around a common python error, so wants to remain if you're keeping the
>> %-formatting.
> What error is that?

>>> def p1(arg):
...     print("%s" % arg)
>>> def p2(arg):
...     print("%s" % (arg, ))

>>> p1("foo")
foo
>>> p2("foo")
foo

>>> p1(("foo", "bar"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in p1
TypeError: not all arguments converted during string formatting

>>> p2(("foo", "bar"))
('foo', 'bar')


The % operator has some type ambiguity with how it works.  (foo, )
forces arg to be a 1-tuple as far as formatting is concerned.

~Andrew


Reply via email to