[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r40229 - trunk/build

From: Greg Stein <gstein_at_gmail.com>
Date: Tue, 27 Oct 2009 07:58:37 -0400

On Tue, Oct 27, 2009 at 00:14, Blair Zajac <blair_at_orcaware.com> wrote:
> On Oct 26, 2009, at 9:08 PM, Branko Cibej wrote:
>> Blair Zajac wrote:
>>> On Oct 26, 2009, at 8:59 PM, Branko Cibej wrote:
>>>> Blair Zajac wrote:
>>>>>>   # Log the elapsed time.
>>>>>> -    elapsed_time = time.strftime('%H:%M:%S',
>>>>>> -                   time.gmtime(time.time() - start_time))
>>>>>> +    elapsed_time = str(datetime.now() - start_time)
>>>>> You don't need to put the value in str() since you're going to
>>>>> pass it
>>>>> to the % operator below for a %s interpolation, which calls str()
>>>>> on
>>>>> it already.
>>>> No, he doesn't need to. But there shouldn't be any discernible
>>>> difference between calling str() here explicitly, and letting the
>>>> formatter do that later, implicitly. This way it's at least clear
>>>> what's
>>>> going on. I do remember reading somewhere that "explicit is better
>>>> than
>>>> implicit." :)
>>> It is a tiny bit wasteful, since there will be another str() called
>>> on
>>> elapsed_time.
>> I don't think I want to look at the Python sources to see if it skips
>> calling str() for string arguments. :)
>>> Also, it's an integer value and maybe later you want to add those
>>> elapsed times (I'm just making this up), so it's possible you'll
>>> remove the str() later.
>>> Do you always convert something to a string if you the only thing
>>> you're going to do is print it?
>>> Also, I don't think this is clearer, keeping an int and printing it
>>> is
>>> pretty clear :)
>> Well of course it's not an int, it's a datetime.timedelta, otherwise a
>> %d formatter would be more appropriate, no?
> Well, ok, I should have checked that it's not an in int :)
> This is descending to the level of I don't care, but out of curiosity,
> does anybody take the time to use non-%s for string interpolation?
> The code I write and most of the code I see doesn't bother to use non-
> %s unless special formatting is needed, say %10.5f.

Same here. %s always works, so I roll with it.

>> I'll have the mauve with vermillion spots, please.
> Ditto.

You peasants. Anybody who knows anything will tell you to get the
lavender with rose stripes.


Received on 2009-10-27 12:58:58 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.