Re: [Tutor] could somebody please explain...

2014-10-03 Thread Clayton Kirkwood
time to review and comment. Clayton !-Original Message- !From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On !Behalf Of Steven D'Aprano !Sent: Friday, October 03, 2014 6:21 AM !To: tutor@python.org !Subject: Re: [Tutor] could somebody please explain... ! !On Wed, Oct 01

Re: [Tutor] could somebody please explain...

2014-10-03 Thread Steven D'Aprano
On Wed, Oct 01, 2014 at 09:43:29AM -0700, Clayton Kirkwood wrote: > # program to test time and count options > > import datetime,operator, sys > from datetime import time, date, datetime > date = datetime.now() > dayofweek = date.strftime("%a, %b") > print("Today is", dayofweek, date.day, "at ",

Re: [Tutor] could somebody please explain...

2014-10-03 Thread Steven D'Aprano
On Wed, Oct 01, 2014 at 09:43:29AM -0700, Clayton Kirkwood wrote: > In an effort to learn and teach, I present a simple program which measures > the time it takes to the various add functions with the appending results: Well done for making the effort! Now I'm going to tell you all the things yo

Re: [Tutor] could somebody please explain...

2014-10-01 Thread Danny Yoo
> !> Also, I found something that I can’t get my mind around. It is part of > !> the time/date protocols. I’ve not seen it anywhere else. > !> > !> Datetime(year=blah, blah, blah).date/time() > !> > !> datetime(2013,3,6).date() #returns… > !> datetime.date(2013,3,6) > !> > !> datetime(2013,3,6).tim

Re: [Tutor] could somebody please explain...

2014-10-01 Thread Clayton Kirkwood
!-Original Message- !From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On !Behalf Of Steven D'Aprano !Sent: Tuesday, September 30, 2014 6:38 PM !To: tutor@python.org !Subject: Re: [Tutor] could somebody please explain... ! !On Tue, Sep 30, 2014 at 03:54:42PM -0700, Cl

Re: [Tutor] could somebody please explain...

2014-10-01 Thread Clayton Kirkwood
!-Original Message- !From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On !Behalf Of Steven D'Aprano !Sent: Tuesday, September 30, 2014 7:34 PM !To: tutor@python.org !Subject: Re: [Tutor] could somebody please explain... ! !On Tue, Sep 30, 2014 at 03:54:42PM -0700, Cl

Re: [Tutor] could somebody please explain...

2014-10-01 Thread Clayton Kirkwood
!-Original Message- !From: Danny Yoo [mailto:d...@hashcollision.org] !Sent: Wednesday, October 01, 2014 12:11 AM !To: Clayton Kirkwood !Cc: Python Tutor Mailing List !Subject: Re: [Tutor] could somebody please explain... ! !> Also, I found something that I can’t get my mind around. It

Re: [Tutor] could somebody please explain...

2014-10-01 Thread Alan Gauld
On 01/10/14 03:16, Steven D'Aprano wrote: For example map() which applies a function to a collection. total = map(operator.add, [1,2,3,4,5,6]) is the same result as total = sum([1,2,3,4,5,6]) No, you're thinking of reduce(), not map(). Oops, you're quite right. Apologies. -- Alan G Auth

Re: [Tutor] could somebody please explain...

2014-10-01 Thread Danny Yoo
> Also, I found something that I can’t get my mind around. It is part of the > time/date protocols. I’ve not seen it anywhere else. > > Datetime(year=blah, blah, blah).date/time() > > datetime(2013,3,6).date() #returns… > datetime.date(2013,3,6) > > datetime(2013,3,6).time() #returns… > datetime.ti

Re: [Tutor] could somebody please explain...

2014-09-30 Thread Steven D'Aprano
On Tue, Sep 30, 2014 at 03:54:42PM -0700, Clayton Kirkwood wrote: > Also, I found something that I can't get my mind around. It is part of the > time/date protocols. I've not seen it anywhere else. > > Datetime(year=blah, blah, blah).date/time() > > datetime(2013,3,6).date() #returns. > datetim

Re: [Tutor] could somebody please explain...

2014-09-30 Thread Steven D'Aprano
On Wed, Oct 01, 2014 at 01:58:16AM +0100, Alan Gauld wrote: > On 30/09/14 23:54, Clayton Kirkwood wrote: > >I don't understand the multiplicity of some tools. Namely, why is there a > >'a+b', operator.add(a,b), operator.__add__(a,b), operator.iadd(a,b), > >operator.__iadd__(a,b) and their related o

Re: [Tutor] could somebody please explain...

2014-09-30 Thread Steven D'Aprano
On Tue, Sep 30, 2014 at 03:54:42PM -0700, Clayton Kirkwood wrote: > I don't understand the multiplicity of some tools. Namely, why is there a > 'a+b', operator.add(a,b), operator.__add__(a,b), operator.iadd(a,b), > operator.__iadd__(a,b) and their related operators? The + operator is the public i

Re: [Tutor] could somebody please explain...

2014-09-30 Thread Alan Gauld
On 30/09/14 23:54, Clayton Kirkwood wrote: I don't understand the multiplicity of some tools. Namely, why is there a 'a+b', operator.add(a,b), operator.__add__(a,b), operator.iadd(a,b), operator.__iadd__(a,b) and their related operators? The operator module is there largely to allow you to pass

[Tutor] could somebody please explain...

2014-09-30 Thread Clayton Kirkwood
I don't understand the multiplicity of some tools. Namely, why is there a 'a+b', operator.add(a,b), operator.__add__(a,b), operator.iadd(a,b), operator.__iadd__(a,b) and their related operators? Also, I found something that I can't get my mind around. It is part of the time/date protocols. I've