Re: [Python-3000] Changing the import machinery

2006-04-22 Thread Brett Cannon
On 4/22/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > > > I'm afraid I disagree. PEP 302 actually has some tremendous advantages > > > over a pure objects-on-sys.path approach: > > > > > > * Strings can be put in any configuration file, and used in .pth files > > > > >

Re: [Python-3000] Changing the import machinery

2006-04-22 Thread Nick Coghlan
Ian Bicking wrote: > Maybe you wouldn't have to mix it all together... if sys.path, > sys.meta_path, and sys.modules (and maybe some other stuff I don't know > of) were really instance variables of some ModuleEnvironment object, and > you could instantiate a new ModuleEnvironment that was specif

Re: [Python-3000] Changing the import machinery

2006-04-22 Thread Fredrik Lundh
Guido van Rossum wrote: > > I'm afraid I disagree. PEP 302 actually has some tremendous advantages > > over a pure objects-on-sys.path approach: > > > > * Strings can be put in any configuration file, and used in .pth files > > > > * Strings can be put in environment variables (like PYTHONPATH).

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Greg Ewing
Phillip J. Eby wrote: > So, what I'd suggest is that the expanded import mechanism would provide a > registry of extensions and handlers, Urg, global registries again. I'd like this better if the scope of a particular extension and its handler could be restricted to some chosen part of the pack

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Greg Ewing
Ian Bicking wrote: > No, I haven't; I assume you mean: > > from string import Template or from mypackage.backports.string24 > import Template No, I mean from string or mypackage.backports.string24 import Template which seems to be about the least ugly it can get given that you need to ex

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Osvaldo Santana
Hi, I've another subject related to import machinery to add in this thread. We've discussed about this at py-dev when I found an inconsistent import/zipimport behavior with .pyc/.pyo compiled modules: http://mail.python.org/pipermail/python-dev/2005-November/057959.html http://mail.python.org/pip

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Phillip J. Eby
At 11:37 AM 4/21/2006 -0500, Ian Bicking wrote: >Phillip J. Eby wrote: >>The second is that PEP 302 only covers "location" importers, not "format" >>importers. That is, if you want to do something like make Kid or Cheetah >>templates importable, you have to replace things with new >>machinery.

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Ian Bicking
Phillip J. Eby wrote: > The second is that PEP 302 only covers "location" importers, not "format" > importers. That is, if you want to do something like make Kid or Cheetah > templates importable, you have to replace things with new machinery. This > is a more important problem to solve, IMO,

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Phillip J. Eby
At 10:05 PM 4/21/2006 +1000, Nick Coghlan wrote: >Phillip J. Eby wrote: >>There are only two things wrong with PEP 302 IMO, and neither is its "fault". >>The first is that the "classic" import machinery isn't on sys.meta_path, >>and the 'imp' API isn't defined in terms of PEP 302. Those two thing

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Thomas Wouters
On 4/21/06, Ian Bicking <[EMAIL PROTECTED]> wrote: Greg Ewing wrote:> Have you seen my proposal for "or" in import statements?> Would you consider that elegant enough?No, I haven't; I assume you mean:   from string import Template or from mypackage.backports.string24import Template... that (realis

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Phillip J. Eby
At 10:42 AM 4/21/2006 +0100, Guido van Rossum wrote: >I think I like this. I wonder if there's a parallel with my preference >for strings as paths instead of path objects... PEP 302 still has things analagous to path objects, it's just that you're allowed to define the mapping between strings and

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Ian Bicking
Greg Ewing wrote: > Ian Bicking wrote: >>try: >> from string import Template >>except ImportError: >> from mypackage.backports.string24 import Template >> >>Doing this in a more elegent or formalized fashion might be nice. > > > Have you seen my proposal for "or" in import statements? >

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Nick Coghlan
Phillip J. Eby wrote: > There are only two things wrong with PEP 302 IMO, and neither is its "fault". > > The first is that the "classic" import machinery isn't on sys.meta_path, > and the 'imp' API isn't defined in terms of PEP 302. Those two things > can't change without introducing backward

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Giovanni Bajo
Greg Ewing <[EMAIL PROTECTED]> wrote: >> 2) Totally disallow recursive imports (!). > > That would be extremely undesirable. I've used languages > in which mutual imports weren't possible, and it's a > massive pain in the posterior. You end up having to > modularise things in awkward and unnatural

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Guido van Rossum
On 4/20/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > I'm afraid I disagree. PEP 302 actually has some tremendous advantages > over a pure objects-on-sys.path approach: > > * Strings can be put in any configuration file, and used in .pth files > > * Strings can be put in environment variables (l

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Greg Ewing
Ian Bicking wrote: > try: > from string import Template > except ImportError: > from mypackage.backports.string24 import Template > > Doing this in a more elegent or formalized fashion might be nice. Have you seen my proposal for "or" in import statements? Would you consider that eleg

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Greg Ewing
Giovanni Bajo wrote: > 2) Totally disallow recursive imports (!). That would be extremely undesirable. I've used languages in which mutual imports weren't possible, and it's a massive pain in the posterior. You end up having to modularise things in awkward and unnatural ways to get around the res

Re: [Python-3000] Changing the import machinery

2006-04-21 Thread Just van Rossum
Phillip J. Eby wrote: > There are only two things wrong with PEP 302 IMO, and neither is its > "fault". > > The first is that the "classic" import machinery isn't on > sys.meta_path, and the 'imp' API isn't defined in terms of PEP 302. > Those two things can't change without introducing backward

Re: [Python-3000] Changing the import machinery

2006-04-20 Thread Phillip J. Eby
At 04:33 PM 4/20/2006 +0100, "Guido van Rossum" <[EMAIL PROTECTED]> wrote: >On 4/20/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > Guido van Rossum wrote: > > > > > On 4/20/06, in python-dev, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > > I was hoping that for Python 3.0, we could get around to

Re: [Python-3000] Changing the import machinery

2006-04-20 Thread Ian Bicking
Jim Jewett wrote: > On 4/20/06, Ian Bicking <[EMAIL PROTECTED]> wrote: > > >>With the ambiguity of sys.path, it's hard to statically determine if you >>have all the requirements. > > > [And, as you said elsewhere, whether it is the version you expected, > and whether it will actually load or ge

Re: [Python-3000] Changing the import machinery

2006-04-20 Thread Jim Jewett
On 4/20/06, Ian Bicking <[EMAIL PROTECTED]> wrote: > With the ambiguity of sys.path, it's hard to statically determine if you > have all the requirements. [And, as you said elsewhere, whether it is the version you expected, and whether it will actually load or get skipped because of an earlier im

Re: [Python-3000] Changing the import machinery

2006-04-20 Thread Giovanni Bajo
Guido van Rossum wrote: >> * Circular imports should fail more nicely. Everyone suffers this at >> some time; maybe it can't be fixed, but at least it should be clear >> what's happening. > > It probably can't be fixed (or do you see a fix?). Do you mean it > should be easier to debug, or do you

Re: [Python-3000] Changing the import machinery

2006-04-20 Thread Ian Bicking
Guido van Rossum wrote: > It must not be my day. I don't understand anything you're saying. Hmm... well, trying again... > On 4/20/06, Ian Bicking <[EMAIL PROTECTED]> wrote: > >>Cleaning up import stuff would be excellent. Time spent debugging >>imports is time wasted, but it happens all too of

Re: [Python-3000] Changing the import machinery

2006-04-20 Thread Guido van Rossum
It must not be my day. I don't understand anything you're saying. On 4/20/06, Ian Bicking <[EMAIL PROTECTED]> wrote: > Cleaning up import stuff would be excellent. Time spent debugging > imports is time wasted, but it happens all too often. > > I would argue against any list of loaders, or list o

Re: [Python-3000] Changing the import machinery

2006-04-20 Thread Ian Bicking
Guido van Rossum wrote: > I'm changing the list and the subject, pulling this quote out of python-dev: > > On 4/20/06, in python-dev, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >>I was hoping that for Python 3.0, we could get around to unkludge the >>sys.path/meta_path/path_hooks/path_importer_ca

Re: [Python-3000] Changing the import machinery

2006-04-20 Thread Guido van Rossum
On 4/20/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > > On 4/20/06, in python-dev, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > I was hoping that for Python 3.0, we could get around to unkludge the > > > sys.path/meta_path/path_hooks/path_importer_cache big ball of ha

Re: [Python-3000] Changing the import machinery

2006-04-20 Thread Fredrik Lundh
Guido van Rossum wrote: > On 4/20/06, in python-dev, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > I was hoping that for Python 3.0, we could get around to unkludge the > > sys.path/meta_path/path_hooks/path_importer_cache big ball of hacks, > > possibly by replacing sys.path with something a bit m

[Python-3000] Changing the import machinery

2006-04-20 Thread Guido van Rossum
I'm changing the list and the subject, pulling this quote out of python-dev: On 4/20/06, in python-dev, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > I was hoping that for Python 3.0, we could get around to unkludge the > sys.path/meta_path/path_hooks/path_importer_cache big ball of hacks, > possibly