[Tutor] could somebody please explain...

Clayton Kirkwood crk at godblessthe.us
Wed Oct 1 00:54:42 CEST 2014


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 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.time(0,0)

 

This is one of the weirder things I've run across. Is this allowed/needed in
other functions/classes, or is it a datetime thing only?

 

Please spare my mind:<))

 

Clayton

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140930/b5705174/attachment.html>


More information about the Tutor mailing list