#14052: Error on a code in Tutorial 01
-------------------------------------+--------------------------------------
Reporter: wagnerluis1982 | Owner: nobody
Status: closed | Milestone:
Component: Documentation | Version: 1.2
Resolution: invalid | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------+--------------------------------------
Changes (by kmtracey):
* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0
Comment:
The tutorial code is correct. Try it in a Python shell:
{{{
#!python
>>> import datetime
>>> datetime.date.today()
datetime.date(2010, 8, 3)
}}}
The proposed change does not work:
{{{
#!python
>>> import datetime
>>> datetime.today().date()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'today'
>>>
}}}
Using the `today()` constructor of the `datetime.datetime` class instead
of trying it on the `datetime` module (yes, this is a bit confusing in
Python) would work:
{{{
#!python
>>> import datetime
>>> datetime.datetime.today().date()
datetime.date(2010, 8, 3)
>>>
}}}
But the existing code is simpler and works, so is preferable.
--
Ticket URL: <http://code.djangoproject.com/ticket/14052#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.