Package importing problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tonguç Yumruk

    Package importing problem

    Hi,

    I'm writing a plugin based application with python 2.1 but I really have
    some trouble with creating a package. My directory structure is:


    Skib/Server/Python/:
    skib
    skibserver

    Skib/Server/Python/skib:
    __init__.py
    PluginManager.p y
    plugins

    Skib/Server/Python/skib/plugins:
    default
    __init__.py

    Skib/Server/Python/skib/plugins/default:
    default.py
    __init__.py

    in all the __init__.py files I have the __all__=["blah","bla h"]
    statement. When I try it as:

    from skib import PluginManager
    PluginManager.i nit_plugins()

    It works. But when I try it like that:

    import skib
    skib.PluginMana ger.init_plugin s()

    It raises AttributeError and complains that there is nothing called
    PluginManager. Subpackages also behave like that. The __init__.py files
    only contain the __all__ directive. No actual code are in them. Am I
    missing a point?

    Thanks.

    --
    Love, Respect, Linux
    ############### ############### ############### ############### ############### #
    Whom computers would destroy, they must first drive mad.
    ############### ############### ############### ############### ############### #
    Tonguç Yumruk

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.2 (GNU/Linux)

    iD8DBQE/WuAo1xWu4MLSyoY RAlh+AKCJSV5XTM 9ek+E6CjIN1kJmR DDUXwCg3wGn
    //5/Q80TfREQk9pjrRX BJes=
    =iL4M
    -----END PGP SIGNATURE-----

  • Peter Otten

    #2
    Re: Package importing problem

    Tonguç Yumruk wrote:
    [color=blue]
    > Hi,
    >
    > I'm writing a plugin based application with python 2.1 but I really have
    > some trouble with creating a package. My directory structure is:
    >
    >
    > Skib/Server/Python/:
    > skib
    > skibserver
    >
    > Skib/Server/Python/skib:
    > __init__.py
    > PluginManager.p y
    > plugins
    >
    > Skib/Server/Python/skib/plugins:
    > default
    > __init__.py
    >
    > Skib/Server/Python/skib/plugins/default:
    > default.py
    > __init__.py
    >
    > in all the __init__.py files I have the __all__=["blah","bla h"]
    > statement. When I try it as:
    >
    > from skib import PluginManager
    > PluginManager.i nit_plugins()
    >
    > It works. But when I try it like that:
    >
    > import skib
    > skib.PluginMana ger.init_plugin s()
    >
    > It raises AttributeError and complains that there is nothing called
    > PluginManager. Subpackages also behave like that. The __init__.py files
    > only contain the __all__ directive. No actual code are in them. Am I
    > missing a point?
    >
    > Thanks.
    >[/color]

    I think that is because skib/PluginManager.p y was never imported. Putting

    import PluginManager

    into skib/__init__.py should do (just a guess, though).

    Peter

    Comment

    Working...