Paul Moore wrote: > 2009/10/1 Eric Smith <eric at trueblade.com>: > >> It's tangential, but in the str.format case you don't want to check for just >> '{asctime}', because you might want '{asctime:%Y-%m-%d}', for example. >> >> But there are ways to delay computing the time until you're sure it's >> actually being used in the format string, without parsing the format string. >> Now that I think of it, the same technique could be used with %-formatting: >> > > Still tangential, but it seems to me that this discussion has exposed > a couple of areas where the logging interface is less than ideal: > > - The introspection of the format string to delay computing certain > items (Eric's suggestion may be an improvement here). > - The "call str() on any non-string object to get a format string" API > (which precludes string subclasses). > Calling str on non-string objects to get a format string does not (prima-facie) preclude string subclasses: >>> class X(str): pass ... >>> class Y(object): ... def __str__(self): ... return X('foo') ... >>> a = Y() >>> type(str(a)) <class '__main__.X'> Michael > I suspect other APIs will exist with similar issues once the whole > question of supporting multiple format syntaxes gets wider > publicity... > > Paul. > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4