string.format() stops working correctly in my script
<p>I have this format string:</p>

<pre><code>print "{u: &lt;16}  {l: &gt;16}  {lse: &lt;19}  {active: &lt;12}".format(...)
</code></pre>

<p>which works fine in the Python console, but when run in my program, it prints <code>&lt;19</code> (literally) for the <code>lse</code> part. When I remove the <code>&lt;19</code> in the format specifier for <code>lse</code>, it does work...</p>

<p>My data is fine, because when just using plain <code>{u}</code>, etc, the correct data is printed.</p>

<p><strong>Update</strong> the field is a <code>datetime</code> field. How can I print a <code>datetime</code> field using the format specifiers?</p>

<p>Apparently, a <code>datetime</code> object does not abide by the format specifier rules. When cast to a <code>str</code>, it works:</p>

<pre><code>print "{d: &lt;12}".format(str(datetime.datetime.now()))
</code></pre>

python format