[ python-Bugs-1087216 ] datetime module documentation missing critical detail

SourceForge.net noreply at sourceforge.net
Fri Dec 17 23:28:47 CET 2004


Bugs item #1087216, was opened at 2004-12-17 14:22
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1087216&group_id=5470

Category: Documentation
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Meyer (mwm)
Assigned to: Nobody/Anonymous (nobody)
Summary: datetime module documentation missing critical detail

Initial Comment:
The datetime documentation - both pydoc and the manual - fail to
specify the arguments used to create a date/time/datetime object. The
manual implies that for date it's date(year, month, day), but that's
about it.

It would be nice if both could be extended to include examples. For date, say:

datetime.date(2004, 12, 25) - create a date object for christmas, 2004.

I can't give examples for time and datetime, because I'm not sure what
the format is.



----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-12-17 17:28

Message:
Logged In: YES 
user_id=80475

It looks like the docstrings could be a bit more informative:

>>> print datetime.date.__doc__
Basic date type.

Compare that with:

>>> print collections.deque.__doc__
deque(iterable) --> deque object

Build an ordered collection accessible from endpoints only.

----------------------------------------------------------------------

Comment By: Skip Montanaro (montanaro)
Date: 2004-12-17 16:05

Message:
Logged In: YES 
user_id=44345

Pydoc generates documentation based upon what it finds in
docstrings
and function signatures.  It can't get at the signatures of
functions
written in C.  In Python 2.4 pydoc generates a link to a
local or online
version of the docs for the subject module:

    NAME
	datetime - Fast implementation of the datetime type.

    FILE
	/Users/skip/local/lib/python2.5/lib-dynload/datetime.so

    MODULE DOCS
	http://www.python.org/doc/current/lib/module-datetime.html

    CLASSES
	__builtin__.object
	    date
		datetime
     ...

I think that's the best that can be done short of macroizing
the hell
out of C extension modules to allow function signatures to be
captured as attributes attached to the functions, similar to
what
GNU Emacs did many years ago.  Correct me if I'm wrong, but
I don't
think we want to go down that path (take a peek at the Emacs
source
if you are in doubt).


----------------------------------------------------------------------

Comment By: Mike Meyer (mwm)
Date: 2004-12-17 15:23

Message:
Logged In: YES 
user_id=93910

You're right - I was just blind when reading the module documenation.

It would still be nice if I could get that information from
pydoc/help, though.




----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2004-12-17 14:56

Message:
Logged In: YES 
user_id=31435

I'm not sure which docs you're looking at.  I'm looking at the 
Python docs <wink>, like here:

http://docs.python.org/lib/datetime-date.html

That seems very clear to me:

"""
class date(year, month, day) 

All arguments are required. Arguments may be ints or longs, in 
the following ranges: 

MINYEAR <= year <= MAXYEAR 
1 <= month <= 12 
1 <= day <= number of days in the given month and year 
If an argument outside those ranges is given, ValueError is 
raised. 
"""

There are equally precise docs for all the datetime.* classes.  
For example, you mentioned time:

"""
class time(hour[, minute[, second[, microsecond[, tzinfo]]]]) 

All arguments are optional. tzinfo may be None, or an 
instance of a tzinfo subclass. The remaining arguments may 
be ints or longs, in the following ranges: 

0 <= hour < 24 
0 <= minute < 60 
0 <= second < 60 
0 <= microsecond < 1000000. 

If an argument outside those ranges is given, ValueError is 
raised. All default to 0 except tzinfo, which defaults to None. 
"""

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1087216&group_id=5470


More information about the Python-bugs-list mailing list