import file extensions
a quick question: i'm working on a pythonic build system, where the build scripts are plain python files. but i want to differentiate them from normal python files (.py) by a different suffix (say .pyy), but then i can't import them. so i'm wondering, is there a quick way to just add another extension to import mechanism? or do i have to write a fully fledged import hook? -tomer
I think you're looking for a PEP 302 style meta hook. On 9/14/07, tomer filiba <tomerfiliba@gmail.com> wrote:
a quick question: i'm working on a pythonic build system, where the build scripts are plain python files. but i want to differentiate them from normal python files (.py) by a different suffix (say .pyy), but then i can't import them.
so i'm wondering, is there a quick way to just add another extension to import mechanism? or do i have to write a fully fledged import hook?
-tomer
_______________________________________________ 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/guido%40python.org
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
Guido van Rossum wrote:
I think you're looking for a PEP 302 style meta hook.
Or even execfile in a context... Michael Foord http://www.manning.com/foord
On 9/14/07, tomer filiba <tomerfiliba@gmail.com> wrote:
a quick question: i'm working on a pythonic build system, where the build scripts are plain python files. but i want to differentiate them from normal python files (.py) by a different suffix (say .pyy), but then i can't import them.
so i'm wondering, is there a quick way to just add another extension to import mechanism? or do i have to write a fully fledged import hook?
-tomer
_______________________________________________ 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/guido%40python.org
so i'm wondering, is there a quick way to just add another extension to import mechanism? or do i have to write a fully fledged import hook?
[this question is off-topic for python-dev] If recompiling Python is an option, the quick way is to edit the interpreter, and add that extension. If that is not an option, but it is an option to put all .pyy files in a single directory, the quick way is to add an entry to sys.path_hooks. If that is also not an option, the quick way is to add an entry to sys.meta_path. The best way would be to not use import, but provide a separate function (e.g. calling it "require"). Regards, Martin
On 9/14/07, "Martin v. Löwis" <martin@v.loewis.de> wrote:
The best way would be to not use import, but provide a separate function (e.g. calling it "require").
yepp, that's probably the cleanest and quickest solution. i needed to see all the alternatives to realize this though. sorry. -- An NCO and a Gentleman
participants (4)
-
"Martin v. Löwis" -
Guido van Rossum -
Michael Foord -
tomer filiba