On Tue, Nov 30, 2010 at 00:34, Sylvain Thénault
<sylvain.thena...@logilab.fr> wrote:
> On 29 novembre 14:21, Ron Adam wrote:
>> On 11/29/2010 01:22 PM, Brett Cannon wrote:
>> >Considering these semantics changed between Python 2 and 3 w/o a
>> >discernable benefit (I would consider it a negative as finding a
>> >module should not be impacted by syntactic correctness; the full act
>> >of importing should be the only thing that cares about that), I would
>> >consider it a bug that should be filed.
>>
>> The output of imp.find_module() returns an open file io object, and
>> it's output feeds directly into to imp.load_module().
>>
>> >>> imp.find_module('pydoc')
>> (<_io.TextIOWrapper name=4 encoding='utf-8'>,
>> '/usr/local/lib/python3.2/pydoc.py', ('.py', 'U', 1))
>>
>> So I think the imp.find_module() is suppose to be used when you *do*
>> want to do the full act of importing and not for just finding out if
>> or where module xyz exists.
>
> in python 2, find_module was usable for such usage, and this is a needed api
> for a tool like pylint. Is there another way to do so with python 3?

At the moment, no. Best option would be to create an
importlib.find_module function which returns a loader if the module is
found, else returns None. The loader can have its get_source method
called to read the source code (w/o verification). I have this planned
for Python 3.3 but not 3.2 with us so close to 3.2b1.

> --
> Sylvain Thénault                               LOGILAB, Paris (France)
> Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
> Développement logiciel sur mesure:       http://www.logilab.fr/services
> CubicWeb, the semantic web framework:    http://www.cubicweb.org
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/brett%40python.org
>
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to