[Tutor] generating independent random numbers

Ewald Ertl ewald.ertl at gmail.com
Wed Sep 29 12:30:41 CEST 2010


Hi,

On Wed, Sep 29, 2010 at 11:42 AM, Peter Otten <__peter__ at web.de> wrote:

> Carter Danforth wrote:
>
> > Thanks for the replies, Dave and Joel. The reason I'm not just using the
> > time or datetime modules for a random date is because it's restricted to
> > 1970-2038; I'm pulling dates from 1600-3099. Thanks a lot for the pointer
>
> The datetime module is not restricted to 1970...2038. It allows years
> 1...9999 (it uses the Gregorian calendar even before its adoption).
>
> >>> import datetime
> >>> datetime.MINYEAR, datetime.MAXYEAR
> (1, 9999)
> >>> datetime.date(1500, 2, 29)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ValueError: day is out of range for month
> >>> datetime.date(1600, 2, 29)
> datetime.date(1600, 2, 29)
>
> Just an attempt from my side:
The year 1500 didn't have a 29th of February, the 28th work for me but 29th
also fails here.
>>> datetime.date( 1500, 2, 28 )
datetime.date(1500, 2, 28)
>>> datetime.date( 1500, 2, 29 )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: day is out of range for month


HTH
Ewald
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100929/e07517da/attachment.html>


More information about the Tutor mailing list