On Sep 29, 2009, at 11:15 PM, Martin v. Löwis wrote:

I would propose that the format argument gets an argument name,
according to the syntax it is written in. For PEP 3101 format,
I would call the argument "format" (like the method name of the
string type), i.e.

logging.Formatter(
 format="{asctime} - {name} - {levelname} - {message}")

For the % formatting, I suggest "dicttemplate" (assuming that
you *have* to use dictionary %(key)s style currently).

The positional parameter would also mean dicttemplate, and
would be deprecated (eventually requiring a keyword-only
parameter).

Although I hate the name 'dicttemplate', this seems like the best solution to me. Maybe it's good that 'dicttemplate' is so ugly though so that people will naturally prefer 'format' :). But I like this because there's not really any magic, it's explicit, and the decision is made by the coder at the call site. The implementation does not need to guess at all.

If this is adopted, it should become a common idiom across Python so that once you've learned how to transition between the format strings, you pretty much know how to do it for any supporting API. So we should adopt it across all of the standard library.

-Barry

Attachment: PGP.sig
Description: This is a digitally signed message part

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

Reply via email to