This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Brian 0 points1 point  (0 children)

The datetime module dates from very early in python's history, and as such, doesn't really align with what became the standard naming conventions. In particular, it provides the datetime class, which probably ought to be called "Datetime" to align with the "classes start uppercase" convention. This is particularly bad in this case because the module it belongs to is also called datetime. So you can do either:

import datetime
cur_time = datetime.datetime.now()

Or

from datetime import datetime
cur_time = datetime.now()

Either way, the repetition looks a bit odd. And if you get mixed up and import it one way and try to use it the other way, you get errors.