Re: (relative) import trouble, sometimes it works, sometimes it doesn't ...

2008-10-20 Thread Gabriel Genellina
En Sat, 18 Oct 2008 05:52:04 -0300, Stef Mientki <[EMAIL PROTECTED]> escribió: I'm running Python 2.5 and want my programs to run at least under Windows and Linux (preferable also Mac). So I guess I should always use relative paths. From most modules I can call a global function, that shou

(relative) import trouble, sometimes it works, sometimes it doesn't ...

2008-10-18 Thread Stef Mientki
hello, I'm running Python 2.5 and want my programs to run at least under Windows and Linux (preferable also Mac). So I guess I should always use relative paths. From most modules I can call a global function, that should import a dictionary from path deeper than the module itself. The import i

RE: Import trouble

2004-12-15 Thread Doran_Dermot
Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Craig Ringer Sent: 15 December 2004 13:45 To: Frans Englich Cc: Python mailing list Subject: Re: Import trouble On Wed, 2004-12-15 at 21:45, Frans Englich wrote: > 2) I use Python modules which are not us

Import trouble

2004-12-15 Thread Frans Englich
Hello all, I have a couple of questions related to module importing. 1) When I start my Python program with `python foo.py` instead of simply adding a interpreter comment on the first line and do `./foo.py`, some "local" imports fails, I guess because current working directory is different. I

Re: Import trouble

2004-12-15 Thread Steve Holden
Frans Englich wrote: Hello all, I have a couple of questions related to module importing. 1) When I start my Python program with `python foo.py` instead of simply adding a interpreter comment on the first line and do `./foo.py`, some "local" imports fails, I guess because current working director

Re: Import trouble

2004-12-15 Thread Frans Englich
On Wednesday 15 December 2004 13:44, Craig Ringer wrote: > On Wed, 2004-12-15 at 21:45, Frans Englich wrote: > > 2) I use Python modules which are not usually installed(libxml2/libxslt) > > and want to fail gracefully in case the modules aren't available; print > > an informative message. Since the

Re: Import trouble

2004-12-15 Thread Craig Ringer
On Wed, 2004-12-15 at 21:44, Craig Ringer wrote: > def import_xml: >try: >import libxml >except ImportError,err: ># handle the error >return libxml > > libxml = import_xml() Though my personal approach would actually be: try: import libxml except ImportError,e

Re: Import trouble

2004-12-15 Thread Craig Ringer
On Wed, 2004-12-15 at 21:45, Frans Englich wrote: > 2) I use Python modules which are not usually installed(libxml2/libxslt) and > want to fail gracefully in case the modules aren't available; print an > informative message. Since these imports are done in several related > programs, I don't wa