473,699 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weird AttributeError With Imports

I'm getting a "AttributeError : 'module' object has no attribute 'clock'"
when importing a module from within two packages related to the line:
"self.lastT ime = time.clock()" in the __init__() of the class Time in
the target module.

The module (mytime.py) sits in a package hierarchy such as the following
"packageA.packa geB.mytime", and imports the Python module "time" like
this: "import time"

In another module outside of both packages (in a folder that holds the
other package folders) I do this:
from packageA.packag eB import mytime

timer = mytime.Time() #Throws the above AttributeError
Strangely it seems that if I create a Time object in mytime.py
everything works perfectly. I have no idea why I'm getting this error,
so any help is welcome!
Oct 28 '07 #1
3 2794
Juha S. wrote:
I'm getting a "AttributeError : 'module' object has no attribute 'clock'"
when importing a module from within two packages related to the line:
"self.lastT ime = time.clock()" in the __init__() of the class Time in
the target module.
You probably have a time module that you wrote yourself and which is now
hiding the one in python's standard library. Was your mytime.py formerly
named time.py, and if so, did you remove the corresponding time.pyc?

Peter
Oct 28 '07 #2
Peter Otten wrote:
Juha S. wrote:

>I'm getting a "AttributeError : 'module' object has no attribute 'clock'"
when importing a module from within two packages related to the line:
"self.lastTi me = time.clock()" in the __init__() of the class Time in
the target module.

You probably have a time module that you wrote yourself and which is now
hiding the one in python's standard library. Was your mytime.py formerly
named time.py, and if so, did you remove the corresponding time.pyc?

Peter
Yes, I did have mytime.py named as time.py previously. Now that I
deleted the .pyc it seems to work fine. Thanks!
Oct 28 '07 #3
En Sun, 28 Oct 2007 14:50:24 -0300, Juha S. <ju*****@gmail. comescribi�:
Peter Otten wrote:
>You probably have a time module that you wrote yourself and which is now
hiding the one in python's standard library. Was your mytime.py formerly
named time.py, and if so, did you remove the corresponding time.pyc?

Yes, I did have mytime.py named as time.py previously. Now that I
deleted the .pyc it seems to work fine. Thanks!
Wow! Most standard crystall balls would tell just about the time.py
problem. Yours is certainly a very sophisticated one! It was even capable
of detecting a rename and a forgotten .pyc file - that's far beyond the
usual range! Congratulations !

--
Gabriel Genellina

Oct 29 '07 #4

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

Similar topics

3
1914
by: Gonçalo Rodrigues | last post by:
Hi, I use the unittest module for testing a given module's functionality, by lumping several test classes and then at the end a simple if __name__ == "__main__": unittest.main() In one of these, I get, at a DOS prompt the following weird result:
2
9524
by: dont bother | last post by:
Hey, I am trying to run the following example from diveintopython import urllib sock = urllib.urlopen("http://diveintopython.org/") htmlSource = sock.read() sock.close() print htmlSource
0
2045
by: Erlend Fuglum | last post by:
I have tried and tried, but cannot figure out the source of the following error: AttributeError: 'module' object has no attribute 'menyHMTL' __doc__ = 'Attribute not found.' __getitem__ = <bound method AttributeError.__getitem__ of <exceptions.AttributeError instance at 0x8187984>> __init__ = <bound method AttributeError.__init__ of <exceptions.AttributeError instance at 0x8187984>> __module__ = 'exceptions'
1
1467
by: George Sakkis | last post by:
I came across a strange error when trying to define a settable property for a new-style subclass of UserArray (Numeric). Here's a shorter example that reproduces the problem: from UserArray import UserArray from math import hypot class Vector(UserArray,object): def __init__(self,x,y):
14
2962
by: Nak | last post by:
Hi there, It's probably me being weird more than the function but I'm having problems with it doing as it should. I have a C++ application with 2 resources of custom types, RT_INIFILE @ 2000 (INI file) and
16
1353
by: iwdu15 | last post by:
hi, i have a few forms in my project. when i load form1 (startup for) all is fine, then i open another one and use a login screen to call yet another and all is still fine, but then when i try to open another form from a 3rd form, it gives this error on form1 "An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module. Additional information: Object reference not set to an instance of an object."
0
1640
by: kepioo | last post by:
I am running a script (summary.py) which is calling the method logException in another module ( pytool). Yesterday, ard 18:50, all of a sudden summary.py was throwing the exception : AttributeError: 'module' object has no attribute 'logException' What I did to fix it was to delete the compiled version of the pytool
5
1980
by: robinsiebler | last post by:
I have a data structure that looks like this: # dates = {'2007': {'25': {'06/23/07': {'aerosmith': , # 'Metallica': }, # 'last_song': }}} I have a section where I try to loop through a set of dates and print out all of the songs for a given artist: if type == 'artist':
3
1623
by: ssecorp | last post by:
I was looking into currying and Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) on win32 Type "copyright", "credits" or "license()" for more information. **************************************************************** Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to...
0
8686
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
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9033
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
8911
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
8882
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...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5872
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
4375
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...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.