1463370 On 4/3/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > Crutcher Dunnavant wrote: > > >>> 1. Shouldn't there be a format method, like S.format(), or S.fmt()? > > > Why? Because: > > > 1 It is trivially cheap, format() would be the same function as __rmod__ > > No it shouldn't be. format() should be a varargs function; __rmod__ > takes a single argument which may be a tuple. Also, format() could > take keyword args in case the string contains named format, so I can > write e.g. "%(foo)s".format(foo=123).
Yes, In doing a patch for this against 2.5 (sf:1463370), I saw the issue there. I tossed it to python-dev for comment, and was smacked down for lack of a PEP. I suppose I could write up a PEP for this, if you think it's worthwhile. > > > 2 It adds consistency with lower(), strip(), and other methods which > > > produce new strings. > > I'm not sure that's much of an argument. I think it is for newibes, but that isn't a deal maker. > > > > 3 I am not arguing _against_ syntactic support, I am arguing _for_ a > > > method; > > > we can keep the syntactic support. > > But remember TOOWTDI from the Zen of Python. which is why we have d.get(k) and d[k]; k in d and d.has_key(k), etc. > On 4/2/06, Walter Dörwald <[EMAIL PROTECTED]> wrote: > > 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). > > In fact, now that I think of it, if s.format() were available, I'd use > it in preference over s%x, just like I already use repr(x) in favor of > `x`. And just like `x` is slated for removal in Python 3000, we might > consider removing using % for formatting. The main reason probably > being the problem Walter points out (which is very real). > > -- > --Guido van Rossum (home page: http://www.python.org/~guido/) > -- Crutcher Dunnavant <[EMAIL PROTECTED]> littlelanguages.com monket.samedi-studios.com _______________________________________________ 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
