Eric V. Smith added the comment:
>> But that would require some discussion, to decide on the correct behaviour.
>What open question(s) do you think of?
You need to provide an exact specification of what you want. It's not clear,
for example, if you want to support required positional placeholders ({0},
etc.) but optionally missing named placeholders ({foo}).
I'd also suggest implementing this as a function, so you can get some
real-world usage out of it. Maybe:
def format_safe(s, *args, **kwargs):
format_safe("{0} {1} {foo} {bar}", 'one', 'two', bar='bar')
->
'one two {foo} bar}'
or whatever you decide the signature and functionality should be.
You can probably subclass from string.Formatter to do some of the heavy lifting
for you, so I expect this wouldn't be very hard, depending on what you're
really after.
While you might find this function useful, I don't want to get your hopes up
that this would be added to core Python as a member of str. I still don't see
why this would be better than a single call to .format() that specifies all of
the parameters. You'd have to have some use case that doesn't involve chaining
for that to make sense (to me). And maybe functools.partial() or some
derivative would make sense in that case.
----------
status: open -> pending
versions: +Python 3.7 -Python 3.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24549>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com