[Python-Dev] python3k : imp.find_module raises SyntaxError (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Wed Dec 1 08:41:07 CET 2010


On Wed, Dec 1, 2010 at 3:59 PM, Ron Adam <rrr at ronadam.com> wrote:

Yes, it's realising that it is a lot more complicated, that gets me. Flawed isn't the right word, it's rather a feeling things could have been simpler if perhaps some things were done differently.

That feeling I can understand. The import system has steadily acquired features over time, with each addition constrained by backwards compatibility concerns with all the past additions, including the exotic hacks people were using to fake features that were added more cleanly later.

For the directory-as-module-not-package idea, you could probably implement a PEP 302 importer/loader that did that (independent of the stdlib). It would have the advantage of avoiding a lot of the pickle compatibility problems that a "flat package" like the new unittest layout can cause. However, you would need to be very careful with it, since all the files would be sharing a common globals() namespace.

Cheers, Nick.

-- Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-Dev mailing list