On Tue, 14 Aug 2007 21:12:32 -0500 Ron Adam <[EMAIL PROTECTED]> wrote:
> > > Greg Ewing wrote: > > Guido van Rossum wrote: > >> On 8/13/07, Andrew James Wade <[EMAIL PROTECTED]> wrote: > >> > >>> On Mon, 13 Aug 2007 20:53:26 -0700 > >>> "Guido van Rossum" <[EMAIL PROTECTED]> wrote: > > > >>>> I propose that their > >>>> __format__ be defined like this: > >>>> > >>>> def __format__(self, spec): > >>>> return self.strftime(spec) > >>> You loose the ability to align the field then. > > > > This might be a use case for the chaining of format specs > > that Ron mentioned. Suppose you could do > > > > "{{1:spec1}:spec2}".format(x) > > > > which would be equivalent to > > > > format(format(x, "spec1"), "spec2") That would be a solution to my concerns, though that would have to be: "{ {1:spec1}:spec2}" > > > What I was thinking of was just a simple left to right evaluation order. > > "{0:spec1, spec2, ... }".format(x) > > I don't expect this will ever get very long. The first __format__ will return a str, so chains longer than 2 don't make a lot of sense. And the delimiter character should be allowed in spec1; limiting the length of the chain to 2 allows that without escaping: "{0:spec1-with-embedded-comma,}".format(x) My scheme did the same sort of thing with spec1 and spec2 reversed. Your order makes more intuitive sense; I chose my order because I wanted the syntax to be a generalization of formatting strings. Handling the chaining within the __format__ methods should be all of two lines of boilerplate per method. -- Andrew _______________________________________________ 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