[CalendarServer-changes] [11343] CalendarServer/trunk/twext/python/log.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Jun 13 16:07:12 PDT 2013


Revision: 11343
          http://trac.calendarserver.org//changeset/11343
Author:   glyph at apple.com
Date:     2013-06-13 16:07:12 -0700 (Thu, 13 Jun 2013)
Log Message:
-----------
A nice docstring.

Modified Paths:
--------------
    CalendarServer/trunk/twext/python/log.py

Modified: CalendarServer/trunk/twext/python/log.py
===================================================================
--- CalendarServer/trunk/twext/python/log.py	2013-06-13 23:07:11 UTC (rev 11342)
+++ CalendarServer/trunk/twext/python/log.py	2013-06-13 23:07:12 UTC (rev 11343)
@@ -162,6 +162,22 @@
 
 def formatWithCall(formatString, mapping):
     """
+    Format a string like L{unicode.format}, but:
+
+        - taking only a name mapping; no positional arguments
+
+        - with the additional syntax that an empty set of parentheses
+          correspond to a formatting item that should be called, and its result
+          C{str}'d, rather than calling C{str} on the element directly as
+          normal.
+
+    For example::
+
+        >>> formatWithCall("{string}, {function()}.",
+        ...                dict(string="just a string",
+        ...                     function=lambda: "a function"))
+        'just a string, a function.'
+
     @param formatString: A PEP-3101 format string.
     @type formatString: L{unicode}
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130613/234da10e/attachment-0001.html>


More information about the calendarserver-changes mailing list