En Thu, 06 Sep 2007 14:41:42 -0300, Samuel <[EMAIL PROTECTED]> escribi�:
> On Sep 6, 6:44 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>> On 6 sep, 13:13, Samuel <[EMAIL PROTECTED]> wrote:
>>
>> That's fine, and a good requirement. Place start2.py inside the
>> container directory, and your package beneath it. Then you don't have
>> to modify sys.path to find the package - "import packagename" just
>> works. And it still works if the user installs the package (into site-
>> packages, by example).
>>
>>  start1.py
>>  start2.py
>>  packagename/
>>  |-- Obj.py
>>  |-- __init__.py
>>  |-- foo/
>>      |-- FooTest.py
>>      `-- __init__.py
>>
>> Packages are... well, packages, boxes. Don't try to import a module
>> inside a package as it were a standalone module
>
> But the start2.py script *is* part of the library. It should be in the
> package.

If it imports the package, it cannot be part of the package itself.

> However, I just found that Python 2.5 introduces relative imports.
> This sounds like an attempt to remedy the situation.

For relative imports to work, the importing module must know that it is  
part of a package. That is not the case if you run a script located inside  
the package.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to