Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

import file extensions

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


tomerfiliba at gmail

Sep 14, 2007, 1:30 PM

Post #1 of 4 (309 views)
Permalink
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

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


guido at python

Sep 14, 2007, 2:11 PM

Post #2 of 4 (272 views)
Permalink
Re: import file extensions [In reply to]

I think you're looking for a PEP 302 style meta hook.

On 9/14/07, tomer filiba <tomerfiliba [at] gmail> 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 [at] python
> 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/)
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


martin at v

Sep 14, 2007, 2:19 PM

Post #3 of 4 (275 views)
Permalink
Re: import file extensions [In reply to]

> 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

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


tomerfiliba at gmail

Sep 14, 2007, 2:34 PM

Post #4 of 4 (285 views)
Permalink
Re: import file extensions [In reply to]

On 9/14/07, "Martin v. Löwis" <martin [at] v> 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
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.