Thank you for answers :)
I used Cédric Lucantis's way to resolve this problem and it works :D
--
http://mail.python.org/mailman/listinfo/python-list
Thank you for answers.
I used Cédric Lucantis's way to resolve this problem and it works :D
--
http://mail.python.org/mailman/listinfo/python-list
On 2008-06-24, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I am new in Python, so I count for your help. I need to get difference
> in months between two dates. How to do it in python? I am substracting
> two dates, for example date1 - date2 and I got result in days, how to
> change it?
Le Tuesday 24 June 2008 12:11:03 [EMAIL PROTECTED], vous avez écrit :
> Hi!
>
> I am new in Python, so I count for your help. I need to get difference
> in months between two dates. How to do it in python? I am substracting
> two dates, for example date1 - date2 and I got result in days, how to
> c
Hi!
I am new in Python, so I count for your help. I need to get difference
in months between two dates. How to do it in python? I am substracting
two dates, for example date1 - date2 and I got result in days, how to
change it?
Best regards
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth schreef:
> flupke <[EMAIL PROTECTED]> wrote:
>
>> Using 86400 instead of (24*60*60) is faster
>
> s/is/was/
>
> upgrade to Python 2.5
Indeed, i'm still on 2.4.
I thought 2.5 might give a different result :)
Thanks for the info
Benedict
--
http://mail.python.org/mailman/listinfo/p
flupke <[EMAIL PROTECTED]> wrote:
> Using 86400 instead of (24*60*60) is faster
s/is/was/
upgrade to Python 2.5
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh schreef:
>
def get_seconds(td):
> ... return td.days * (24*60*60) + td.seconds
> ...
import dis
dis.dis(get_seconds)
> 2 0 LOAD_FAST0 (td)
> 3 LOAD_ATTR0 (days)
> 6 LOAD_CONST 4
Steven D'Aprano wrote:
> Arguably a better solution would be to do this:
>
> seconds = td.days * 24*60*60 + td.seconds
if you're targeting an audience that cannot figure out what the
expression does based on the names of the result and the names of the
attributes, chances are that 24*60*60 won
In message <[EMAIL PROTECTED]>,
Steven D'Aprano wrote:
> On Wed, 27 Sep 2006 20:16:52 +0200, Fredrik Lundh wrote:
>
>> Claes at work wrote:
>>
>>> Please tell me there is a simpler way than subtracting two datetimes
>>> to get a timedelta and then compute
>>>
>>> days * number of seconds per da
Steven D'Aprano wrote:
> On Wed, 27 Sep 2006 20:16:52 +0200, Fredrik Lundh wrote:
>
>> Claes at work wrote:
>>
>>> Please tell me there is a simpler way than subtracting two datetimes
>>> to get a timedelta and then compute
>>>
>>> days * number of seconds per day + seconds
>>>
>>> from it myself?
Steven D'Aprano wrote in
news:[EMAIL PROTECTED] in
comp.lang.python:
> On Wed, 27 Sep 2006 20:16:52 +0200, Fredrik Lundh wrote:
>
>> Claes at work wrote:
>>
>>> Please tell me there is a simpler way than subtracting two datetimes
>>> to get a timedelta and then compute
>>>
>>> days * number of
On Wed, 27 Sep 2006 20:16:52 +0200, Fredrik Lundh wrote:
> Claes at work wrote:
>
>> Please tell me there is a simpler way than subtracting two datetimes
>> to get a timedelta and then compute
>>
>> days * number of seconds per day + seconds
>>
>> from it myself??
>
> why would you have to do
On 9/27/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Claes at work wrote:
>
> why would you have to do that yourself? why not let Python do it for
> you? here's the code:
>
> seconds = td.days * 86400 + td.seconds
>
Thanks, but that is exactly what I meant. I had hoped there would some
met
Claes> calculating the difference between two dates in seconds
>>> import datetime
>>> now1 = datetime.datetime.now()
>>> # dum dee dum ...
... now2 = datetime.datetime.now()
>>> now2-now1
datetime.timedelta(0, 12, 781540)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Claes at work wrote:
> Please tell me there is a simpler way than subtracting two datetimes
> to get a timedelta and then compute
>
> days * number of seconds per day + seconds
>
> from it myself??
why would you have to do that yourself? why not let Python do it for
you? here's the code:
Hi,
I am learning Python and want to perform what I think is a very simple
task: calculating the difference between two dates in seconds. Reading
through the documentation I am puzzled: I can't find a way to do this
without doing manually what I think belongs to a standard library
m
17 matches
Mail list logo