Re: import bug

2009-11-04 Thread Mark Leander
On Oct 31, 5:12 pm, kj wrote: > I give up: what's the trick? (Of course, renaming ham/re.py is > hardly "the trick." It's rather Procrustes' Bed.) I realize that this is probably not the answer you were looking for, but: $ python -m ham.spam or ==> ./spammain.py <== import ham.spam $ python

Re: import bug

2009-11-03 Thread Gabriel Genellina
En Tue, 03 Nov 2009 12:29:10 -0300, Ask Solem escribió: If you have a module named myapp.django, and someone writes a cool library called django that you want to use, you can't use it unless you rename your local django module. file myapp/django.py: from django.utils.functional import

Re: import bug

2009-11-03 Thread Ask Solem
On Nov 3, 1:52 am, Carl Banks wrote: > On Oct 31, 7:12 am, kj wrote: > > > > > > > I'm running into an ugly bug, which, IMHO, is really a bug in the > > design of Python's module import scheme.  Consider the following > > directory structure: > > > ham > > |-- __init__.py > > |-- re.py > > `-- sp

Re: import bug

2009-11-02 Thread Carl Banks
On Oct 31, 7:12 am, kj wrote: > I'm running into an ugly bug, which, IMHO, is really a bug in the > design of Python's module import scheme.  Consider the following > directory structure: > > ham > |-- __init__.py > |-- re.py > `-- spam.py > > ...with the following very simple files: > > % head ha

Re: import bug

2009-11-01 Thread Gabriel Genellina
En Sun, 01 Nov 2009 19:51:04 -0300, Steven D'Aprano escribió: On Sun, 01 Nov 2009 17:34:19 -0300, Gabriel Genellina wrote: En Sun, 01 Nov 2009 02:54:15 -0300, Steven D'Aprano escribió: Shadowing a standard library module is no different. But that's what namespaces are for; if the standard

Re: import bug

2009-11-01 Thread Gabriel Genellina
En Sun, 01 Nov 2009 19:01:42 -0300, MRAB escribió: Gabriel Genellina wrote: One way to avoid name clashes would be to put the entire standard library under a package; a program that wants the standard re module would write "import std.re" instead of "import re", or something similar. You c

Re: import bug

2009-11-01 Thread Steven D'Aprano
On Sun, 01 Nov 2009 17:34:19 -0300, Gabriel Genellina wrote: > En Sun, 01 Nov 2009 02:54:15 -0300, Steven D'Aprano > escribió: >> On Sun, 01 Nov 2009 01:38:16 -0300, Gabriel Genellina wrote: > Incorrect. Simplicity of implementation and API is a virtue, in and of itself. The existing m

Re: import bug

2009-11-01 Thread MRAB
Gabriel Genellina wrote: [snip] One way to avoid name clashes would be to put the entire standard library under a package; a program that wants the standard re module would write "import std.re" instead of "import re", or something similar. Every time the std package is suggested, the main argume

Re: import bug

2009-11-01 Thread Gabriel Genellina
En Sun, 01 Nov 2009 02:54:15 -0300, Steven D'Aprano escribió: On Sun, 01 Nov 2009 01:38:16 -0300, Gabriel Genellina wrote: Incorrect. Simplicity of implementation and API is a virtue, in and of itself. The existing module machinery is quite simple to understand, use and maintain. Uhm... mod

Re: import bug

2009-10-31 Thread Steven D'Aprano
On Sun, 01 Nov 2009 01:38:16 -0300, Gabriel Genellina wrote: >> Incorrect. Simplicity of implementation and API is a virtue, in and of >> itself. The existing module machinery is quite simple to understand, >> use and maintain. > > Uhm... module objects might be quite simple to understand, but mo

Re: import bug

2009-10-31 Thread Gabriel Genellina
En Sat, 31 Oct 2009 12:12:21 -0300, kj escribió: I'm running into an ugly bug, which, IMHO, is really a bug in the design of Python's module import scheme. The basic problem is that the "import scheme" was not designed in advance. It was a very simple thing at first. Then came packages. And

Re: import bug

2009-10-31 Thread Steven D'Aprano
On Sat, 31 Oct 2009 16:27:20 +, kj wrote: >>1) it's a bad idea to name your own modules after modules in the stdlib > > Obviously, since it leads to the headaches this thread illustrates. But > there is nothing intrisically wrong with it. The fact that it is > problematic in Python is a desi

Re: import bug

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 16:27 +, kj wrote: > >2) this has been fixed in Py3 > > In my post I illustrated that the failure occurs both with Python > 2.6 *and* Python 3.0. Did you have a particular version of Python > 3 in mind? I was not able to reproduce with my python3: $ head ham/*

Re: import bug

2009-10-31 Thread kj
In <4aec591e$0$7629$9b4e6...@newsspool1.arcor-online.net> Stefan Behnel writes: >kj, 31.10.2009 16:12: >> My sin appears to be having the (empty) file ham/re.py. So Python >> is confusing it with the re module of the standard library, and >> using it when the inspect module tries to import re.

Re: import bug

2009-10-31 Thread Stefan Behnel
kj, 31.10.2009 16:12: > My sin appears to be having the (empty) file ham/re.py. So Python > is confusing it with the re module of the standard library, and > using it when the inspect module tries to import re. 1) it's a bad idea to name your own modules after modules in the stdlib 2) this has be

Re: import bug

2009-10-31 Thread Jon Clements
On Oct 31, 3:12 pm, kj wrote: > I'm running into an ugly bug, which, IMHO, is really a bug in the > design of Python's module import scheme.  Consider the following > directory structure: > > ham > |-- __init__.py > |-- re.py > `-- spam.py > > ...with the following very simple files: > > % head ha

import bug

2009-10-31 Thread kj
I'm running into an ugly bug, which, IMHO, is really a bug in the design of Python's module import scheme. Consider the following directory structure: ham |-- __init__.py |-- re.py `-- spam.py ...with the following very simple files: % head ham/*.py ==> ham/__init__.py <== ==> ham/re.py <==

import bug?

2009-02-20 Thread alain
Hi all, Running python 2.5, i experience a strange behaviour with the following code:import imputil def handle_pye(fullpath, fileinfo, name): # Print a debugging message print 'Importing "%s" from "%s"' % (name,fullpath) data = open(fullpath).read() return 0, compile(data,fullpath

Re: Relative import bug or not?

2006-10-14 Thread [EMAIL PROTECTED]
Alexey Borzenkov wrote: > After reading PEP-0328 I wanted to give relative imports a try: > > # somepkg/__init__.py > > > # somepkg/test1.py > from __future__ import absolute_import > from . import test2 > > if __name__ == "__main__": > print "Test" > > # somepkg/test2.py > > > But it compla

Relative import bug or not?

2006-10-14 Thread Alexey Borzenkov
After reading PEP-0328 I wanted to give relative imports a try: # somepkg/__init__.py # somepkg/test1.py from __future__ import absolute_import from . import test2 if __name__ == "__main__": print "Test" # somepkg/test2.py But it complaints: C:\1\somepkg>test1.py Traceback (most recent c

Re: Import bug: Module executed twice when imported!

2006-06-30 Thread Michael Abbott
In article <[EMAIL PROTECTED]>, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > Set __name__ to 'subtest' as it would be if you had really imported > subtest and the import system will correctly name the modules, causing > imptest to be imported only once. Ach. I get it now. -- http://mail.py

Re: Import bug: Module executed twice when imported!

2006-06-30 Thread Georg Brandl
Peter Maas wrote: > The docs tell us > (http://www.python.org/doc/2.4.2/lib/built-in-funcs.html): > > - begin --- > execfile(filename[, globals[, locals]]) > > This function is similar to the exec statement, but parses a file > instead of a str

Re: Import bug: Module executed twice when imported!

2006-06-30 Thread Peter Maas
Michael Abbott wrote: > In article <[EMAIL PROTECTED]>, > Michael Abbott <[EMAIL PROTECTED]> wrote: > >> --- test.py --- >> import imptest >> execfile('subtest.py', dict(__name__ = 'subtest.py')) >> --- imptest.py --- >> print 'Imptest imported' >> --- subtest.py --- >> import imptest >> --- >> >

Re: Import bug: Module executed twice when imported!

2006-06-30 Thread Jean-Paul Calderone
On Fri, 30 Jun 2006 19:13:00 +0100, Michael Abbott <[EMAIL PROTECTED]> wrote: >Bump > >In article <[EMAIL PROTECTED]>, > Michael Abbott <[EMAIL PROTECTED]> wrote: > >> --- test.py --- >> import imptest >> execfile('subtest.py', dict(__name__ = 'subtest.py')) >> --- imptest.py --- >> print 'Imptest

Re: Import bug: Module executed twice when imported!

2006-06-30 Thread Michael Abbott
Bump In article <[EMAIL PROTECTED]>, Michael Abbott <[EMAIL PROTECTED]> wrote: > --- test.py --- > import imptest > execfile('subtest.py', dict(__name__ = 'subtest.py')) > --- imptest.py --- > print 'Imptest imported' > --- subtest.py --- > import imptest > --- > >$ python test.py >Impt