473,395 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Whither datetime.date ?

I'm confused. I was going to try linkchecker, and it dies with a
traceback ending in

File "/usr/local/lib/python2.4/calendar.py", line 32, in _localized_month
_months = [datetime.date(2001, i+1, 1).strftime for i in range(12)]
AttributeError: 'module' object has no attribute 'date'

Sure enough, there is no datetime.date, but there is a datetime.Date:

Python 2.4 (#2, Feb 19 2005, 20:35:23)
[GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
Type "help", "copyright", "credits" or "license" for more information.
import datetime
dir(datetime)

['Date', 'DateTime', ...]

However, the Library Reference clearly states that datetime.date
should exist. Granted, it's been a while since I used python in
anger, but isn't this what it says?

http://www.python.org/doc/2.4/lib/node243.html
http://www.python.org/doc/2.4/lib/datetime-date.html

Moreover, the datetime.date class is supposed to have a strftime()
method. datetime.Date does not.

I'm beginning to wonder if the FreeBSD python package is at fault.

Or what is really going on here?

--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
than thinking does: but it deprives us of whatever chance there is
of getting closer to the truth. -- C.P. Snow
Jul 18 '05 #1
3 2521
Harald Hanche-Olsen wrote:
I'm beginning to wonder if the FreeBSD python package is at fault.


Maybe - at my system, it has no Date or DateTime

Python 2.4.1a0 (#2, Feb 9 2005, 12:50:04)
[GCC 3.3.5 (Debian 1:3.3.5-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import datetime
dir(datetime) ['MAXYEAR', 'MINYEAR', '__doc__', '__file__', '__name__', 'date',
'datetime', 'datetime_CAPI', 'time', 'timedelta', 'tzinfo']

Maybe this is a clash between a custom datetime module and the python one?

What does

python2.4 -v -c "import datetime"

give you?
--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
[Harald Hanche-Olsen]
I'm confused. I was going to try linkchecker, and it dies with a
traceback ending in

File "/usr/local/lib/python2.4/calendar.py", line 32, in _localized_month
_months = [datetime.date(2001, i+1, 1).strftime for i in range(12)]
AttributeError: 'module' object has no attribute 'date'

Sure enough, there is no datetime.date, but there is a datetime.Date:

Python 2.4 (#2, Feb 19 2005, 20:35:23)
[GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
Type "help", "copyright", "credits" or "license" for more information.
import datetime
dir(datetime)

['Date', 'DateTime', ...]

However, the Library Reference clearly states that datetime.date
should exist. Granted, it's been a while since I used python in
anger, but isn't this what it says?

http://www.python.org/doc/2.4/lib/node243.html
http://www.python.org/doc/2.4/lib/datetime-date.html

Moreover, the datetime.date class is supposed to have a strftime()
method. datetime.Date does not.

I'm beginning to wonder if the FreeBSD python package is at fault.

Or what is really going on here?


As you've deduced, you're certainly not getting Python's builtin
datetime module. Therefore you must be getting some other datetime
module. Run Python with the "-v" switch to get output telling you how
imports are resolved. That will show you where this other datetime
module is coming from. Remember that Python searches along sys.path
to resolve imports, taking the first thing it finds with the right
name. You almost certainly have something _called_ datetime earlier
in your PYTHONPATH than where the standard Python libraries appear.
Jul 18 '05 #3
+ Tim Peters <ti********@gmail.com>:

| As you've deduced, you're certainly not getting Python's builtin
| datetime module.

Argh. Yeah, I've had one lying around in my personal python directory
since 2000, had totally forgotten it was there. This one ...

*** Author: Jeff Kunce <ku****@mail.conservation.state.mo.us>
*** Download from: http://starship.skyport.net/crew/jjkunce

Removed it, now all is well.

Thanks for pointing out the blindingly obvious.

--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
than thinking does: but it deprives us of whatever chance there is
of getting closer to the truth. -- C.P. Snow
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
4
by: John Hunter | last post by:
>>> from datetime import date >>> dt = date(1005,1,1) >>> print dt.strftime('%Y') Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: year=1005 is before 1900; the...
6
by: MarkAurit | last post by:
Im having difficulty coming up with a good algorithm to express the following comparison: "if <a given date> falls between the (current date - 5 days) and the (current date)" Obviously....
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
1
by: Mike Rooney | last post by:
Hi everyone, this is my first post to this list. I am trying to create a subclass of datetime.date and pickle it, but I get errors on loading it back. I have created a VERY simple demo of this: ...
10
by: kyosohma | last post by:
Hi, I am working on a timesheet application in which I need to to find the first pay period in a month that is entirely contained in that month to calculate vacation time. Below are some example...
1
by: Christian Heimes | last post by:
Rick King schrieb: datetime.date is a C extension class. Subclassing of extension classes may not always work as you'd expect it. Christian
2
by: Will Rocisky | last post by:
Actually I am trying to save both date and time in one cell but they are given separately by user.
7
by: w41ter | last post by:
I'm writing a very simple python program to read in an ascii csv file with multiple records formatted like this: "2010.3.13, 0.0.0, 10.1, 12.2, 9.9, 10.1, 2500" # i.e. a list of daily stock...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.