Crutcher Dunnavant wrote:

> On 4/2/06, Georg Brandl <[EMAIL PROTECTED]> wrote:
>> Crutcher Dunnavant wrote:
>>> Python currently supports  'S % X', where S is a strinng, and X is one of:
>>> * a sequence
>>> * a map
>>> * treated as (X,)
>>>
>>> But I have some questions about this for python 3000.
>>>
>>> 1. Shouldn't there be a format method, like S.format(), or S.fmt()?
>> Possible, but why? "%" works quite fine. "Abusing" the modulus operator
>> is okay in this context since the symbol gives a nonoverseeable clue to
>> what the construct is doing.
> 
> Why? Because:
> 1 It is trivially cheap, format() would be the same function as __rmod__
> 2 It adds consistency with lower(), strip(), and other methods which
> produce new strings.
> 3 I am not arguing _against_ syntactic support, I am arguing _for_ a method;
>    we can keep the syntactic support.

and it avoids one problem you might run into with %: If you have only 
one argument, writing ``s % (x,)`` as ``s % x`` will break when the 
argument x happens to be a tuple. You won't have this problem with 
s.format(x).

Bye,
    Walter Dörwald

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to