> 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?
Can you say more about what you expect? It may help to be very explicit, even if it seems silly. The problem with talking with experienced tutors and programmers is that our perspective has warped slightly from extended exposure. :P So we may need a bit of hinting to tell what you're referring to by weirdness. The datetime library, if I recall correctly, combines two things: the date part, and the time part, each which are otherwise treated separately. It's a composite object. https://docs.python.org/2/library/datetime.html#datetime-objects When we construct a datetime.datetime, at the very least we need to provide its year, month, and day, but the other "time" components of it are optional. That's what the documentation is trying to say when it wraps the arguments in braces here: https://docs.python.org/2/library/datetime.html#datetime.datetime If you don't provide the time-related arguments, I think it assumes that those components are zeroed out. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor