473,698 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with datetime

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.
import datetime
d = datetime.dateti me.today()
d datetime.dateti me(2004, 12, 10, 6, 13, 28, 154472)


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

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

Traceback (most recent call last):
File "datetime.p y", line 1, in ?
import datetime
File "/home/bob/pyshow/datetime.py", line 3, in ?
d = datetime.dateti me.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

Jul 18 '05 #1
2 3977
On Fri, Dec 10, 2004 at 04:19:56AM -0800, bn******@cs.com wrote:
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.
import datetime
d = datetime.dateti me.today()
d datetime.dateti me(2004, 12, 10, 6, 13, 28, 154472)

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

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

Traceback (most recent call last):
File "datetime.p y", line 1, in ?
import datetime
File "/home/bob/pyshow/datetime.py", line 3, in ?

^^^^^^^^^^^
d = datetime.dateti me.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.


Change your script's name from datetime.py to something else. Otherwise the
script will import itself, and not the datetime module from the standard
library.

-- Gerhard
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBuZXddIO 4ozGCH14RApIoAJ 9viDHd8FYHAYv+c d0rvdeaQjL/RACfVZm6
3t42eLZdhQ3jVlU wPtjjEHM=
=0c2v
-----END PGP SIGNATURE-----

Jul 18 '05 #2
Bob
Thanks. That did it. And I know better than to use the module name.
Bob

Jul 18 '05 #3

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

Similar topics

2
908
by: Keith | last post by:
I am having a problem creating a many-to-many-to-many type relationship. It works fine, but when I create a view to query it and test it, it does not generate the results I expected. Below if the DDL for the tables and the SQL for the view.
3
2064
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
5
1998
by: I am Sam | last post by:
I have created this DateTime object and instanced it I think correctly DateTime myClubNow1=new DateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day,DateTime.Now.Hour,DateTime.Now.Minute,DateTime.Now.Second); I keep getting the below error: Object reference not set to an instance of an object. I don't know what the problem could be. Can someone help me with this? It
15
2009
by: Cesar Ronchese | last post by:
Hi, I built the sample code showing the problem with dates when viewed at different machines, different Time Zones and transported via Remoting. The zip can be downloaded here: www.carsoftnet.com.br/temp/sample_error_date.zip
3
7723
by: Jason Huang | last post by:
Hi, In our C# Windows Form application, we are using the SQL Server 2000 as the database server. The Database table MyTable has a field RegistrationDate which represents the Date a client comes to our company to deliver his product. We have some Working days for processing his product, like 20, 30, 40 days. My question is how do I handle the working days problem, e.g., a client comes at the Days February 15 where we have 40 Working...
2
4550
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
3
3132
by: pranesh.nayak | last post by:
I'm facing an error:"String was not recognized as a valid DateTime" whille accessing DateTime from webservice. And when I try to set DateTime to the same webservice it fails with error:"Date value is of wrong type" it looks like xs:DateTime is not compatible with .Net DateType. Any suggestions on how to fix this without touching the webservice (3rd party webservice)?
6
1856
by: JFieseler | last post by:
Hi all, in a huge project i have the following problem. I create an object which contains many private members (i know that this is not correct, but it is a single use migration program). The members will be filled from database tables. In the fill method i see in debug mode the correct values. At the source where i create the object the DateTime members of the object are not present (error: cannot obtain value). An statement like this...
5
2598
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field (MSSQL Server) it worked on my test machine. If I run the same application on another machine with different regional settings is not working. I tried with date_default_timezone_set to change timezone but is not changing. After...
4
3694
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I am having a problem formatting a string when the time is in format hh.mm.ss - used in Europe Parse seems ok when the date uses "/" or "." as seperator but I get an exception when time uses "." as seperator as used in Europe I have US regional setting and I have tried switching my regional setting to Europe
0
8671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8887
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.