Parent module idea dropped? [WAS: import statement - package visibility problem]

2005-04-08 Thread Laszlo Zsolt Nagy
But onto the point you're making. I think its possibly a mis-viewing of the package idea in Python. A package creates a name space. If you create Lib/Server/Db with all the __init__.py files, its because you want to import Lib.Server.Db, rather than a way of organising your source files. I

Re: import statement - package visibility problem

2005-04-08 Thread Paul Clinch
Laszlo, ... Importing from a not package related source code is not a problem, really. My problem is about importing inside a package. Lib/Server/Db/__init__.py __can__ import Lib/Server/Db/Adapters usign relative paths, but Lib/Server/Db/Adapters/PostgreSQLConnection.py __cannot__

import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
Hi All! I have the following structure: /Lib/Server/Db/ __init_.py DatabaseConnection.py Adapters/ __init__.py FireBirdConnection.py Important file contents are: /Lib/Server/Db/__init__.py: import DatabaseConnection import Adapters /Lib/Server/Db/DatabaseConnection.py:

Re: import statement - package visibility problem

2005-04-07 Thread Kristóf Stróbl
Hi! Laszlo Zsolt Nagy wrote: I have the following structure: /Lib/Server/Db/ __init_.py DatabaseConnection.py Adapters/ __init__.py FireBirdConnection.py Important file contents are: /Lib/Server/Db/__init__.py: import DatabaseConnection import Adapters

Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
Two solutions come into my mind: 1. Do not inherit from DatabaseConnection, but pass a DatabaseConnection object as a parameter to the FireBirdConnection's __init__function. After this you can delegate the necessary functionality to the DatabaseConnection (by using __getattr__). This

Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
2. Maybe the layering of your application is wrong. If DatabaseConnection provides common functionality to the different Adapters, it should be on the same layer or one beneath the Adapters. Another notice. If I put 'DatabaseConnection' under 'Adapters' then it means that

Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
' under 'Adapters' then it means that 'DatabaseConnection' is an adapter. But it is not. :-) In the other direction, Adapters are deeper, so adapters should can DatabaseConnection-s (and in fact they are). Spelled: In the other direction, Adapter is deeper, so adapters should _be_

Re: import statement - package visibility problem

2005-04-07 Thread Paul Clinch
Laszlo, For :- Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import Lib Traceback (most recent call last): File stdin, line 1, in ? File Lib\__init__.py, line 1, in ? import Server

Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
Paul Clinch wrote: I get: import Lib Traceback (most recent call last): File stdin, line 1, in ? ImportError: No module named Lib I guess there's a Lib/__init__.py. You are totally right. I was trying to create an example but Python found something on my PYTHONPATH. Sorry for

Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
Here is the example: http://designasign.biz/Lib2.zip Please extract the file and try to import Lib2 Although \Lib2\Client\Db\DatabaseConnection.py and \Lib2\Server\Db\DatabaseConnection.py have the same class name but they are in a different sub-package. From a programmer's view, I hope this is