What I think is wrong in Python

datetime.now() vs datetime.today()

datetime.today() returns a datetime WITH the time part.
datetime.now() returns a datetime WITH the time part.
So…
from datetime import datetime
now = datetime.now()
today = datetime.today()
print(now)
print(today)

In other languages today is used to return a date time WITHOUT the time part.

Output:
datetime.datetime(2017, 6, 24, 21, 11, 27, 374230)
datetime.datetime(2017, 6, 24, 21, 12, 1, 166053)

filter(filter_rule, collection) vs filter(collection, filter_rule)

filter(lambda x: x > 1, []) is Correct.
filter(lambda x: x > 1, []) is Wrong.

I expect to have filter(what, how), that means filter(collection, filter) followinth the “pattern” Object.Action.
I think the form filter(collection, filter_rule) is more intuitive.

%y %m %d is embarassing

Every time I have to parse or format a string to a date I need to read the documentation carefully.

Advertisements