[Python-ideas] f-string "debug" conversion

Anders Hovmöller boxed at killingar.net
Wed Oct 3 00:11:04 EDT 2018


> This would be used in debugging print statements, that currently end up looking like:
> 
> print(f'value={value!r}')
> 
> and would now be:
> 
> print(f'{value!d}')

It seems to me that a short form for keyword arguments would improve this situation too. So instead of your suggestion one could do:

print(dict(=value))

And of course this feature wouldn’t be a minor feature on f-strings but a feature that is generally useful and composable so the above could be improved:

def debug(**kwargs):
    for k, v in kwargs.items():
        print(f’{k}={v}’)

debug(=value, =another)

/ Anders 


More information about the Python-ideas mailing list