473,327 Members | 2,007 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,327 software developers and data experts.

mx Oddity in FC3/RedHat ES

Hello!

I've installed the mx package from egenix, and I am experiencing pretty
odd behaviour.

If I launch python and run the following commands, I get an error:
import mx
from mx import *
mx.DateTime.today() Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'DateTime'
OK, great. However, if I then ask for help on the mx package first, the
above command will work.
help() help> modules
-- list of modules --
help> mx
-- displays mx info --
help> mx.DateTime
-- displays mx.DateTime info --
help> --quit help here -- mx.DateTime.today()

<DateTime object for '2004-12-20 00:00:00.00' at 984a1b8>

Any ideas what is going on? Is there a path problem that gets resolved
by calling help()?

Note that issuing help(mx) doesn't work. You have to go into help, do
the modules listing and then ask for mx.

This same behaviour is displayed on my Fedora Core 3 box running
mx-2.0.5-3, and on 2 separate machines running RHEL-ES (most recent
version with updates applied) and egenix-mx-base-2.0.6-py2.2_1.

Any help would be very appreciated!

Thanks,

Eric

p.s. the background is that I need to use mx because the target boxes
only have Python 2.2 on them. Using DateTime from Python 2.3 would be
preferred, but being a newbie, I have no idea how to compile just that
module from source and install it into 2.2. *sigh*
Jul 18 '05 #1
3 1369
Eric Azarcon wrote:
Hello!

I've installed the mx package from egenix, and I am experiencing pretty
odd behaviour.

If I launch python and run the following commands, I get an error:

import mx
from mx import *
mx.DateTime.today() Well,

from anything import *

is bad form for any module unless (like Tkinter, for example) it's been
specifically designed to support this behavior. Since "the mx package"
is actually a number of inter-dependent packages you are almost
guaranteeing trouble here.

mx is not designed to be imported, it's just a common namespace for a
number of modules by the same author.
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'DateTime'
Try:

Python 2.4 (#1, Dec 4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
import mx.DateTime as dt
dt.today() <DateTime object for '2004-12-20 00:00:00.00' at a0d85e0>
OK, great. However, if I then ask for help on the mx package first, the
above command will work.

help()
help> modules
-- list of modules --
help> mx
-- displays mx info --
help> mx.DateTime
-- displays mx.DateTime info --
help> --quit help here --
mx.DateTime.today()


<DateTime object for '2004-12-20 00:00:00.00' at 984a1b8>

Any ideas what is going on? Is there a path problem that gets resolved
by calling help()?

Note that issuing help(mx) doesn't work. You have to go into help, do
the modules listing and then ask for mx.

Well, the help system actually imports the subpackages that live in the
mx space when you ask for help about them. So that's why doing that
allows you to resolve those names.
This same behaviour is displayed on my Fedora Core 3 box running
mx-2.0.5-3, and on 2 separate machines running RHEL-ES (most recent
version with updates applied) and egenix-mx-base-2.0.6-py2.2_1.

Any help would be very appreciated!
It's just a matter of using the packages in the intended way.
Thanks,
No problem.
Eric

p.s. the background is that I need to use mx because the target boxes
only have Python 2.2 on them. Using DateTime from Python 2.3 would be
preferred, but being a newbie, I have no idea how to compile just that
module from source and install it into 2.2. *sigh*


Well the first thing to try would be dropping it into /usr/lib/python2.2
and seeing if you can import it without errors. You might actually find
that the built-in "time" module contains enough date/time functionality
for your needs if they are simple.

regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
Jul 18 '05 #2
In article <dNBxd.57044$Jk5.33616@lakeread01>, Steve Holden
<st***@holdenweb.com> wrote:
from anything import *

is bad form for any module unless (like Tkinter, for example) it's been
Ah, I see. Thank you. Is there any reference, or way for me to
determine whether something can/should be imported in this manner? As a
newbie, looking for this information is sorta tough. I only used
from mx import *
because i found a reference to doing it this way elsewhere on the web.

I also use from stat import * to get at the ST_CTIME constant. Is that
a module that supports this, or is there a better way?
>>> import mx.DateTime as dt
>>> dt.today()

<DateTime object for '2004-12-20 00:00:00.00' at a0d85e0>


Awesome! Thanks, that's what I needed.
Well, the help system actually imports the subpackages that live in the
mx space when you ask for help about them. So that's why doing that
allows you to resolve those names.
Makes sense.
It's just a matter of using the packages in the intended way.
Thanks! I tried to look on the egenix website for usage info, but it
just had API info.

The odd thing is that Egenix has an EXAMPLES link on their page. If you
scroll down and look at the actual code examples, you'll see that it
starts out FROM blah IMPORT *. So, you can understand why I did it that
way. I prolly didn't do it deep enough (stopped at mx instead of
mx.blah).
Well the first thing to try would be dropping it into /usr/lib/python2.2
and seeing if you can import it without errors. You might actually find
that the built-in "time" module contains enough date/time functionality
for your needs if they are simple.


My needs are pretty simple. Maybe you can point me in the right
direction. I need to compare the creation time of a file with a date,
and determine if I need to delete it. I know how to use stat to get the
file creation time. I can get the current time. If I subtract the file
ctime from the current time, how do i turn that delta into days?

Thanks for all your help!

Eric
Jul 18 '05 #3
Eric Azarcon wrote:

[...]


My needs are pretty simple. Maybe you can point me in the right
direction. I need to compare the creation time of a file with a date,
and determine if I need to delete it. I know how to use stat to get the
file creation time. I can get the current time. If I subtract the file
ctime from the current time, how do i turn that delta into days?


sholden@dellboy ~
$ python
Python 2.4 (#1, Dec 4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
from stat import ST_CTIME
from os import stat
s = stat("xmlpractical.txt")
s (33279, 1407374883881497L, 1410850211L, 1, 544, 513,
5859L, 1103556876, 1102382453, 1102292631) ctime = s[ST_CTIME]
ctime 1102292631 import time
print "File was created", (time.time() - ctime)/(3600*24), "days ago"

File was created 14.6398609114 days ago

Does this do it?

regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
Jul 18 '05 #4

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

Similar topics

2
by: Tom Loredo | last post by:
Hi folks- I'm about to move from a Solaris 8/SPARC environment to a Dell running RedHat 9. Are there any issues I need to be aware of in bringing my Python code over (mostly scientific...
1
by: Sebastian Knoop-Troullier | last post by:
I'm having a lot of trouble with Python2.3 on Redhat 7.3 As this is a requirement for the new unstable versions of TMDA I am trying to get this up and running. Is anybody else running Python2.3 on...
2
by: Russell E. Owen | last post by:
I'm trying to build Python 2.3.4 from source on a RedHat Enterprise machine for installation in a net-wide accessible directory /net/python. I tried all of the following variants of ./configure...
2
by: tim | last post by:
I was trying to install Oracle on a Linux box with Redhat and got an error message saying the OS had to be Redhat 2.1 or 3.0 (plus some other non-Redhat versions). Does anyone know what I have to...
3
by: Mark Johnson | last post by:
>>DELURK<< Over the last few weeks, we've been working on building an online portfolio using XML to pass content to an HTML page via PHP. In the process, we've run across a rather inexplicable...
11
by: Daniel E. Fisher | last post by:
> I can't get a rest for a min guys. > > I go away for the weekend and my server is getting this error. > > Fatal error: Call to undefined function: pg_connect() in >...
4
by: D. Dante Lorenso | last post by:
This isn't entirely PG related, but... Does anyone know what the natural upgrade path from RedHat 9 is? I'm wondering if anyone on the PostgreSQL team is working with redhat to package and...
4
by: Uthuras | last post by:
Greetings All, I have situation as such that I need to access the DB2 database reside on a Solaris box. I have DB2 6.1 on my Solaris box. However, my webserver is on Redhat 7.2. Now, I want to...
15
by: Manuel Tejada | last post by:
Hello list This is my situation: My box: Pentium III, Red Hat 9.0 I was working fine with PostgreSQL 7.3.2. Recently I decided to upgrade it to PostgreSQL 7.4 installing the twelve rpms I...
5
by: jmdocherty | last post by:
All, I've been trying to set up a CSS layout and all seems well in Firefox but in Safari it just seems to be plain weird! I hope someone can help tell me whether this is a problem with my code...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.