tangled namespace

0 views
Skip to first unread message

Catherine

unread,
Aug 11, 2009, 9:42:15 AM8/11/09
to sqlpython
I need advice from somebody who really gets Python packaging and
namespacing. (This is my confession that I do not.)

I can't run unit tests against sqlpyPlus.py right now:

catherine@DellZilla:~/proj/sqlpython/sqlpython$ python sqlpyPlus.py
/usr/bin/gedit
Traceback (most recent call last):
File "sqlpyPlus.py", line 26, in <module>
import sys, os, re, sqlpython, cx_Oracle, pyparsing, re,
completion, datetime, pickle, binascii, subprocess, time, itertools,
hashlib
File "/home/catherine/proj/sqlpython/sqlpython/sqlpython.py", line
12, in <module>
import sqlpyPlus, sqlalchemy, pyparsing
File "/home/catherine/proj/sqlpython/sqlpython/sqlpyPlus.py", line
31, in <module>
from sqlpython import Parser
ImportError: cannot import name Parser

I don't understand why it can't do the import, but I can see why it's
hard to figure out. The package is named sqlpython, it includes a
module sqlpython.py, and that module includes a class `sqlpython`...
and sqlpython.py and sqlpyPlus.py both have imports from each other...
OK, that was probably not a real good move strategically.

Short of some massive refactoring effort (which I do daydream of
taking the time for), is there any advice for untangling this snarl?
Do you think it would be good enough to rename the module and the
class - perhaps to `sqlpython_core.py` and `class Cmdloop`? That, at
least, might make it more apparent where the problem is coming from.

Thanks in advance for your advice,

- Catherine

Menno

unread,
Aug 11, 2009, 10:01:21 AM8/11/09
to sqlp...@googlegroups.com
Catherine wrote:
>
> I don't understand why it can't do the import, but I can see why it's
> hard to figure out. The package is named sqlpython, it includes a
> module sqlpython.py, and that module includes a class `sqlpython`...
> and sqlpython.py and sqlpyPlus.py both have imports from each other...
> OK, that was probably not a real good move strategically.
>
> Short of some massive refactoring effort (which I do daydream of
> taking the time for), is there any advice for untangling this snarl?

I think this could be an import loop. If you get rid of the (seemingly
unused?) import of sqlpyPlus at the top of sqlpython.py the problem goes
away.

HTH,
Menno

Catherine Devlin

unread,
Aug 11, 2009, 2:16:56 PM8/11/09
to sqlp...@googlegroups.com
On Tue, Aug 11, 2009 at 10:01 AM, Menno<me...@freshfoo.com> wrote:
> I think this could be an import loop. If you get rid of the (seemingly
> unused?) import of sqlpyPlus at the top of sqlpython.py the problem goes
> away.
>
> HTH,

Well, I can file that one under "simple solutions". Thanks!

--
- Catherine
http://catherinedevlin.blogspot.com/
*** PyOhio * July 25-26, 2009 * pyohio.org ***

Reply all
Reply to author
Forward
0 new messages