bug? pkgutil.walk_packages returns packages that result in an ImportError

Chris Withers chris at simplistix.co.uk
Mon Aug 30 12:55:53 EDT 2010


Peter Otten wrote:
>> My expectation of this is that if onerrors is left as None, names
>> yielded will be importable.
> 
> I would infer no such promise, especially as the generator also yields 
> modules, and no attempt at all is made to import those.

Really? I thought the __import__ fired over everything?

> I've never worked with that function; I'd like to hear more about your 
> usecase.

It's becoming a common use case for packages like martian [1] and 
venutian [2] that need to scan whole packages for things. In my case, 
I'm scanning for declaratively mapped SQLAlchemy models.

It would be great if this function became part of the public API and got 
some more definition on what it will and won't do. When should I take 
this to Python-Dev?

cheers,

Chris

[1] http://pypi.python.org/pypi/martian
[2] http://pypi.python.org/pypi/venusian

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk



More information about the Python-list mailing list