Re: time module vs. datetime module: plain language for beginners

2015-03-27 Thread Ian Kelly
On Fri, Mar 27, 2015 at 6:31 PM, Jinghui Niu wrote: > On Wednesday, March 25, 2015 at 2:17:03 PM UTC-7, Jinghui Niu wrote: >> I am learning python programming. One thing that gives me a lot of confusion >> is the division of labours between the time module and the datetime modu

Re: time module vs. datetime module: plain language for beginners

2015-03-27 Thread Jinghui Niu
On Wednesday, March 25, 2015 at 2:17:03 PM UTC-7, Jinghui Niu wrote: > I am learning python programming. One thing that gives me a lot of confusion > is the division of labours between the time module and the datetime module. > > As it turns out to be, time module is not only abou

Re: time module vs. datetime module: plain language for beginners

2015-03-25 Thread Mark Lawrence
On 25/03/2015 23:49, Ian Kelly wrote: On Wed, Mar 25, 2015 at 3:16 PM, Jinghui Niu wrote: I am learning python programming. One thing that gives me a lot of confusion is the division of labours between the time module and the datetime module. As it turns out to be, time module is not only

Re: time module vs. datetime module: plain language for beginners

2015-03-25 Thread Ian Kelly
On Wed, Mar 25, 2015 at 3:16 PM, Jinghui Niu wrote: > I am learning python programming. One thing that gives me a lot of confusion > is the division of labours between the time module and the datetime module. > > As it turns out to be, time module is not only about time, it's

Re: time module vs. datetime module: plain language for beginners

2015-03-25 Thread Steven D'Aprano
On Thu, 26 Mar 2015 08:16 am, Jinghui Niu wrote: > I am learning python programming. One thing that gives me a lot of > confusion is the division of labours between the time module and the > datetime module. > > As it turns out to be, time module is not only about time, it

time module vs. datetime module: plain language for beginners

2015-03-25 Thread Jinghui Niu
I am learning python programming. One thing that gives me a lot of confusion is the division of labours between the time module and the datetime module. As it turns out to be, time module is not only about time, it's about date too. And datetime doesn't natively support timezone, y

Re: Another surprise from the datetime module

2014-01-30 Thread Ben Finney
Steven D'Aprano writes: > On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: > > > Cameron Simpson writes: > >> Firstly, replace is a verb, and I would normally read > >> td.replace(microseconds=0) as an instruction to modify td in place. > >> Traditionally, such methods in python return None

Re: Another surprise from the datetime module

2014-01-30 Thread Dan Sommers
On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: > However, the existing ‘replace’ methods ‘datetime.date.replace’, > ‘datetime.datetime.replace’, ‘datetime.time.replace’ already work this > way: they create a new value and return it, without modifying the > original object. That's how str.r

Re: Another surprise from the datetime module

2014-01-30 Thread Roy Smith
In article <52eb1e37$0$29972$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > "replace" is a perfectly reasonable name for a method which performs a > replacement, whether it replaces in place (for mutable objects) or makes > a copy with replacement (for immutable objects). What e

Re: Another surprise from the datetime module

2014-01-30 Thread Steven D'Aprano
On Fri, 31 Jan 2014 11:35:14 +1100, Ben Finney wrote: > Cameron Simpson writes: > >> Hmm. I do not like the replace() as suggested. >> >> Firstly, replace is a verb, and I would normally read >> td.replace(microseconds=0) as an instruction to modify td in place. >> Traditionally, such methods in

Re: Another surprise from the datetime module

2014-01-30 Thread Cameron Simpson
On 31Jan2014 11:35, Ben Finney wrote: > Cameron Simpson writes: > > Hmm. I do not like the replace() as suggested. > > > > Firstly, replace is a verb, and I would normally read > > td.replace(microseconds=0) as an instruction to modify td in place. > > Traditionally, such methods in python return

Re: Another surprise from the datetime module

2014-01-30 Thread Ben Finney
Cameron Simpson writes: > Hmm. I do not like the replace() as suggested. > > Firstly, replace is a verb, and I would normally read > td.replace(microseconds=0) as an instruction to modify td in place. > Traditionally, such methods in python return None. I agree with this objection. A method that

Re: Another surprise from the datetime module

2014-01-30 Thread Cameron Simpson
On 30Jan2014 18:36, Neil Cerutti wrote: > On 2014-01-30, Roy Smith wrote: > > I was astounded just now to discover that datetime.timedelta > > doesn't have a replace() method (at least not in Python 2.7). > > Is there some fundamental reason why it shouldn't, or is this > > just an oversight? > >

Re: Another surprise from the datetime module

2014-01-30 Thread Neil Cerutti
On 2014-01-30, Roy Smith wrote: > I was astounded just now to discover that datetime.timedelta > doesn't have a replace() method (at least not in Python 2.7). > Is there some fundamental reason why it shouldn't, or is this > just an oversight? > > My immediate use case was wanting to print a timed

Re: Another surprise from the datetime module

2014-01-30 Thread Mark Lawrence
On 30/01/2014 17:32, Roy Smith wrote: I was astounded just now to discover that datetime.timedelta doesn't have a replace() method (at least not in Python 2.7). Is there some fundamental reason why it shouldn't, or is this just an oversight? My immediate use case was wanting to print a timedelt

Another surprise from the datetime module

2014-01-30 Thread Roy Smith
I was astounded just now to discover that datetime.timedelta doesn't have a replace() method (at least not in Python 2.7). Is there some fundamental reason why it shouldn't, or is this just an oversight? My immediate use case was wanting to print a timedelta without the fractions of seconds. The

Re: datetime module and timezone

2012-02-10 Thread Bob Martin
in 671891 20120210 212545 Olive wrote: >In the datetime module, it has support for a notion of timezone but is >it possible to use one of the available timezone (I am on Linux). Linux >has a notion of timezone (in my distribution, they are stored >in /usr/share/zoneinfo). I would lik

Re: datetime module and timezone

2012-02-10 Thread Chris Rebert
On Fri, Feb 10, 2012 at 1:25 PM, Olive wrote: > In the datetime module, it has support for a notion of timezone but is > it possible to use one of the available timezone (I am on Linux). Linux > has a notion of timezone (in my distribution, they are stored > in /usr/share/zoneinfo).

Re: datetime module and timezone

2012-02-10 Thread John Gordon
In <20120210222545.4cbe6...@bigfoot.com> Olive writes: > In the datetime module, it has support for a notion of timezone but is > it possible to use one of the available timezone (I am on Linux). Linux > has a notion of timezone (in my distribution, they are stored > in /usr/

datetime module and timezone

2012-02-10 Thread Olive
In the datetime module, it has support for a notion of timezone but is it possible to use one of the available timezone (I am on Linux). Linux has a notion of timezone (in my distribution, they are stored in /usr/share/zoneinfo). I would like to be able 1) to know the current timezone and 2) to be

Re: Why datetime module is so complicated?

2010-11-14 Thread Vlastimil Brom
2010/11/14 Zeynel : > It's about a week now I've been trying to convert a datetime object to > seconds since epoch; the object is set to current time by class Rep() > in Google App Engine: > > class Rep(db.Model): >    ... >    mCOUNT = db.IntegerProperty() >    mDATE0 = db.DateTimeProperty(auto_no

Re: Why datetime module is so complicated?

2010-11-14 Thread Diez B. Roggisch
Zeynel writes: > It's about a week now I've been trying to convert a datetime object to > seconds since epoch; the object is set to current time by class Rep() > in Google App Engine: > > class Rep(db.Model): > ... > mCOUNT = db.IntegerProperty() > mDATE0 = db.DateTimeProperty(auto_no

Why datetime module is so complicated?

2010-11-14 Thread Zeynel
It's about a week now I've been trying to convert a datetime object to seconds since epoch; the object is set to current time by class Rep() in Google App Engine: class Rep(db.Model): ... mCOUNT = db.IntegerProperty() mDATE0 = db.DateTimeProperty(auto_now_add=True) mWEIGHT = db.Flo

Re: oddities in the datetime module

2005-01-14 Thread Tim Peters
[Max M] > ... > First of, it should be possible to easily convert between the > datetime objects. Why? All the conversions people asked for when the module was being designed were implemented. > And eg. the date object doesn't have a datetime() method. Which > it could easily have. But not a *s

Re: oddities in the datetime module

2005-01-14 Thread Serge Orlov
Max M wrote: > Serge Orlov wrote: >> Max M wrote: > >> Yes, you did. datetime.timetuple is those who want *time module* >> format, you should use datetime.data, datetime.time, datetime.year >> and so on... As they say, if the only tool you have is timetuple, everything >> looks like tuple Try this

Re: oddities in the datetime module

2005-01-14 Thread Max M
Serge Orlov wrote: Max M wrote: Yes, you did. datetime.timetuple is those who want *time module* format, you should use datetime.data, datetime.time, datetime.year and so on... As they say, if the only tool you have is timetuple, everything looks like tuple Try this: dt = datetime(2005, 1, 1,

Re: oddities in the datetime module

2005-01-14 Thread Serge Orlov
Max M wrote: > # -*- coding: latin-1 -*- > > """ > > I am currently using the datetime package, but I find that the design > is oddly > asymmetric. I would like to know why. Or perhaps I have misunderstood > how it should be used? Yes, you did. datetime.timetuple is those who want *time module* fo

oddities in the datetime module

2005-01-14 Thread Max M
guments (9 given) >>> d1.timetuple() (2005, 1, 1, 12, 13, 10, 5, 1, -1) Because if I subclass datetime, I often need to convert between my subclass and the built in datetime module. But there is no direct way to do it. Instead I have to do it in a somewhat more clunky way:

Re: Datetime module

2005-01-10 Thread Mark McEahern
[EMAIL PROTECTED] wrote: I am writing a script that acts as an AIM bot [using twisted.IM's base scripts] and I want to add a logging feature. I got it to log who sends what to whom, but what I want to add is the date and time that the message was sent (or recieved by the bot), I tried to look at da

Re: Datetime module

2005-01-10 Thread [EMAIL PROTECTED]
take a look at the logging module as well, in the documentation (paragraph 6.29.2 for release 2.4) you find a basic example -- http://mail.python.org/mailman/listinfo/python-list

Re: Datetime module

2005-01-09 Thread Binu K S
The time module will do. >>> import time >>> time.ctime() 'Mon Jan 10 11:17:54 2005' Use strftime if you need to format the time differently. >>> time.strftime("%Y-%m-%d %H:%m:%S",time.localtime()) '2005-01-10 11:01:45' On 9 Jan 2005 21:46:12 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >

Datetime module

2005-01-09 Thread rublind
I am writing a script that acts as an AIM bot [using twisted.IM's base scripts] and I want to add a logging feature. I got it to log who sends what to whom, but what I want to add is the date and time that the message was sent (or recieved by the bot), I tried to look at datetime on my own, and I c

Re: newbie: Datetime module for Python 2.2.x

2004-12-16 Thread Jarek Zgoda
Eric Azarcon wrote: I'm fairly new to Python, and was wondering if someone might be able to help. I'm doing something that requires the datetime module released in 2.3. Unfortunately, the target machines are running 2.2.x and there is no easy way that I know of to install 2.3/2.4 (RHEL

newbie: Datetime module for Python 2.2.x

2004-12-16 Thread Eric Azarcon
Hello! I'm fairly new to Python, and was wondering if someone might be able to help. I'm doing something that requires the datetime module released in 2.3. Unfortunately, the target machines are running 2.2.x and there is no easy way that I know of to install 2.3/2.4 (RHEL ES). I&#x