On 8/17/07, Victor Stinner <[EMAIL PROTECTED]> wrote:
> I didn't read the PEP nor all email discussions. So can you tell me if it
> would be possible to write simply:
> "{} {}".format('Hello', 'World')
If you really want to write this, I suggest adding the following
helper function to your code somewhere::
>>> def fix_format(fmt):
... def get_index(match, indices=itertools.count()):
... return str(indices.next())
... return re.sub(r'(?<={)(?=})', get_index, fmt)
...
>>> fix_format('{} {}')
'{0} {1}'
>>> fix_format('{} {} blah {}')
'{0} {1} blah {2}'
That way, if you really want to bypass the precautions that the new
format strings try to take for you, you can do it in only four lines
of code.
STeVe
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com