Package importing question

Nick Patavalis npat at
Tue Mar 9 16:58:01 CET 2004

Assume this package:

    __init.py__  <-- empty

  $ cat p0/
  import sys
  import m1
  def f0(i):

  $ cat p0/
  def f0(i):

Now let's see what happens when importing the package:

  $ python2.3 
  >>> import p0
  >>> dir(p0)
  ['__builtins__', '__doc__', '__file__', '__name__', '__path__']

so far, so good. Now try:

  >>> import p0.m0
  ['__builtins__', '__doc__', '__file__', '__name__', 'f0', 'm1', 'sys']

fine also! But:

  >>> dir(p0)
  ['__builtins__', '__doc__', '__file__', '__name__', '__path__',
  'm0', 'm1']

Why on earth does 'm1' show-up there?? And since it does, why doesn't

Thanks in advance

More information about the Python-list mailing list