On 02/06/2015 04:44 PM, Ben Finney wrote:
> Ethan Furman <et...@stoneleaf.us> writes:
> 
>> On 02/06/2015 02:56 PM, Ben Finney wrote:
>>> It is a deliberate design decision that direct import of a module
>>> makes that module blind to its location in the package hierarchy.
>>>
>>> That's a design decision I deplore, because it makes something that
>>> should be easy (write a command directly into a file and invoke that
>>> file as an executable program) tortuously difficult when the program
>>> comprises several modules.
>>
>> Can you explain that a bit more?
> 
> A program will often have enough complexity that its implementation
> occupies several sub-modules. There's no need to explose those in a site
> package, they normally only need to be local to the application.

If they are not in the Python module path, how are they imported at all?

> Python deliberately divorces the top-level module from its package, so
> it can't access its own relative modules! The relative import fails with
> an ImportError “Attempted relative import in non-package”.

My understanding is that imports is for libraries [1], and libraries must be in 
sys.path.  Are you saying that after
placing your top-level file's path in sys.path, that relative imports do not 
work?

--
~Ethan~

[1] which can be a single module

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to