Need help optimizing first script

Bengt Richter bokr at
Fri Jun 20 20:33:35 CEST 2003

On 20 Jun 2003 12:59:49 +0100, jjl at (John J. Lee) wrote:

>bokr at (Bengt Richter) writes:
>> On 19 Jun 2003 06:03:22 -0700, popup391 at (Frederic Lafleche) wrote:
>> No one seems to have mentioned strftime yet ;-)
>Um, except the original poster, and me.
You're right. I wonder why the OP defined determineFN when further down he did
use strftime for something very similar.
My comment to the OP re reading docs was off the mark, though. Sorry.

I saw your
def determineFN():
    """Return timestamp in yyyymmddhhmm format."""
    return ("%.4d"+"%.2d"*4) % time.localtime()[:5]

Note docstring style: for example, wording, spacing and use of
triple-double quotes (see the PEP for why).

and suffered a knee-jerk exception before I saw your immediately following

But we can do better.

def timestamp():
    """Return timestamp in yyyymmddhhmm format."""

Bottom line, I'm sympathetic to your
Hey, wait a minute: I just realised you already knew about strftime!
So why a separate function, AND this use of strftime directly?  At
this point I run out of energy.  :-)

You more than adequately covered it, sorry for butting in at all.
I guess was being more (or less?) than lazy ;-/

Bengt Richter

More information about the Python-list mailing list