On Apr 27, 2:30 pm, Tom Evans <tevans...@googlemail.com> wrote:
>
> The datetime class lives inside the datetime module.
So far so good.... but!
> You must have
> "import datetime" in that code, perhaps as well as "from datetime
> import datetime".
The first statement will import the datetime module and bind it to the
name "datetime" in the current namespace. The second will import the
datetime class from the datetime module and bind it to the name
"datetime" in thye current namespace, _in this cas overwriting the
first binding. IOW : you either use the first form and access the
datetime class as "datetime.datetime", or use the second form and
access the datetime class as "datetime", but using both forms is at
once useless and confusing.
As far as I'm concerned, I strongly favor the first form (importing
the module and using the fully qualified name), since there are other
useful stuff in the datetime module and chances are you'll need them
if you need the (badly named) datetime.datetime class.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment