[twill] twill hacking the sys.path

Hervé Cauwelier herve at itaapy.com
Wed May 17 06:22:06 PDT 2006


I had Python errors trying to run a Python script using twill API. I
eventually found out that twill inserts its modules at the top of
sys.path, so that "import utils" did not import my module but twill's.

The best suggestion would be of course to drop this hack, but in the
meantime, I suggest you do not insert your modules at index 0 but 1, in
order to leave the current path at the top.


--- twill-latest/twill/__init__.py      2006-05-17 10:05:04.000000000 +0200
+++ twill-itaapy/twill/__init__.py      2006-05-17 15:20:30.000000000 +0200
@@ -37,13 +37,13 @@

 import sys, os.path
 thisdir = os.path.dirname(__file__)
-sys.path.insert(0, thisdir)
+sys.path.insert(1, thisdir)

 extensions = os.path.join(thisdir, 'extensions/')
-sys.path.insert(0, extensions)
+sys.path.insert(1, extensions)

 wwwsearchlib = os.path.join(thisdir, 'other_packages/')
-sys.path.insert(0, wwwsearchlib)
+sys.path.insert(1, wwwsearchlib)

 # the two core components of twill:
 from shell import TwillCommandLoop


Please note I'm not suscribed to the list.

Hervé Cauwelier, Ingénieur logiciel
SARL ITAAPY 9 rue Darwin, 75018 Paris - Tel +33(0)1 42 23 67 45
Mail: herve at itaapy.com - Fax: 01 53 28 27 88

More information about the twill mailing list