problem with datetime

B

Bob

Relatively new to python. I can get the following to work from the
command line:

Python 2.3.4 (#2, Aug 18 2004, 21:49:15)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
But when I try to run the following small program I get the following
results:

import datetime
d = datetime.datetime.today()
print d

Traceback (most recent call last):
File "datetime.py", line 1, in ?
import datetime
File "/home/bob/pyshow/datetime.py", line 3, in ?
d = datetime.datetime.today()
AttributeError: 'module' object has no attribute 'today'

Do I need to change a path?
Running python 2.3.4 on linux redhat 7.3.

Bob
 
P

Peter Otten

Bob said:
But when I try to run the following small program I get the following
results:

import datetime
d = datetime.datetime.today()
print d

Traceback (most recent call last):
File "datetime.py", line 1, in ?
import datetime

You are importing your script, not the library module here.
File "/home/bob/pyshow/datetime.py", line 3, in ?

Just rename that file to mydatetime.py or something, and you're fine.
But don't forget to delete /home/bob/pyshow/datetime.pyc or .pyo, too.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top