Guido van Rossum 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).
Would "%(foo)s".format({'foo': 123}) work? Or would you need **{...}? FWIW, I suspect I'd be much more likely to use named %'s with .format() than with %; which is probably good, since named markers are more flexible. E.g., I never do: "%(path)s: path %(path)r does not exist" % {'path': path}, but I often do "%s: path %r does not exist" % (path, path). But the first form is really better in several ways. If .substitute() (or .sub()?) was available to do $-based substitution alongside .format() for %-based substitution, that would both have a nice symmetry and make it more comfortable to move between the two. >>>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. Syntactic support does allow for a level of flexibility (evaluation) plus security (special casing literals) that no method can provide. -- Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org _______________________________________________ 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