Has Python 2.4.1 changed implementation for __init__.py???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Werner Merkl

    #1

    Has Python 2.4.1 changed implementation for __init__.py???

    Hallo,


    I just downloaded http://www.python.org/pypi/xexpr/0.02, installed
    if (python setup.py install) and tried the example in the README file.

    Than I got following error: AttributeError: 'module' object has no
    attribute 'Read'

    This is same behavior for all module using empty __init__.pr files,
    like venster, Pyrex or libxmlmods...

    Is there a change in the implementation, so that every module needs an
    explicit list for exchanged modules? Or is there a switch or an
    environment variable to change?


    Thanks a lot
    Werner


    EXAMPLE
    ------------------------------------------------------------------------

    Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
    win32
    Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
    >>> import xexpr
    >>> example = '<foo a="b" c="d"><bar><b az a="d" />Blah</bar></foo>'
    >>> xexpr.Read.to_x expr(example)[/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    AttributeError: 'module' object has no attribute 'Read'[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]
  • Fredrik Lundh

    #2
    Re: Has Python 2.4.1 changed implementation for __init__.py???

    Werner Merkl wrote:
    [color=blue]
    > I just downloaded http://www.python.org/pypi/xexpr/0.02, installed
    > if (python setup.py install) and tried the example in the README file.
    >
    > Than I got following error: AttributeError: 'module' object has no attribute 'Read'
    >
    > This is same behavior for all module using empty __init__.pr files,
    > like venster, Pyrex or libxmlmods...[/color]

    if "xexpr" is a package with an empty __init__.py file, the behaviour you're
    seeing is the expected behaviour. importing a toplevel module doesn't auto-
    matically import any submodules.
    [color=blue]
    > Is there a change in the implementation, so that every module needs an
    > explicit list for exchanged modules?[/color]

    what's an "exchanged module"?
    [color=blue]
    > EXAMPLE
    > ------------------------------------------------------------------------
    >
    > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
    > Type "help", "copyright" , "credits" or "license" for more information.[color=green][color=darkred]
    > >>> import xexpr
    > >>> example = '<foo a="b" c="d"><bar><b az a="d" />Blah</bar></foo>'
    > >>> xexpr.Read.to_x expr(example)[/color][/color]
    > Traceback (most recent call last):
    > File "<stdin>", line 1, in ?
    > AttributeError: 'module' object has no attribute 'Read'[color=green][color=darkred]
    > >>>[/color][/color][/color]

    does it work better if you type

    import xexpr.Read

    before you call the to_xexpr function?

    </F>



    Comment

    • Werner Merkl

      #3
      Re: Has Python 2.4.1 changed implementation for __init__.py???

      Fredrik Lundh wrote:[color=blue]
      > Werner Merkl wrote:
      >
      >[color=green]
      >>I just downloaded http://www.python.org/pypi/xexpr/0.02, installed
      >>if (python setup.py install) and tried the example in the README file.
      >>
      >>Than I got following error: AttributeError: 'module' object has no attribute 'Read'
      >>
      >>This is same behavior for all module using empty __init__.pr files,
      >>like venster, Pyrex or libxmlmods...[/color]
      >
      >
      > if "xexpr" is a package with an empty __init__.py file, the behaviour you're
      > seeing is the expected behaviour. importing a toplevel module doesn't auto-
      > matically import any submodules.[/color]
      Oh, I see. I have to write:
      import xexpr.Read

      Now it works...[color=blue]
      >
      >[color=green]
      >>Is there a change in the implementation, so that every module needs an
      >>explicit list for exchanged modules?[/color]
      >
      >
      > what's an "exchanged module"?[/color]
      Oops! This should say "every module"...

      Thanx a lot
      Werner[color=blue]
      >
      >[color=green]
      >>EXAMPLE
      >>------------------------------------------------------------------------
      >>
      >>Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
      >>Type "help", "copyright" , "credits" or "license" for more information.
      >>[color=darkred]
      >>>>>import xexpr
      >>>>>example = '<foo a="b" c="d"><bar><b az a="d" />Blah</bar></foo>'
      >>>>>xexpr.Read .to_xexpr(examp le)[/color]
      >>
      >>Traceback (most recent call last):
      >> File "<stdin>", line 1, in ?
      >>AttributeErro r: 'module' object has no attribute 'Read'
      >>[/color]
      >
      > does it work better if you type
      >
      > import xexpr.Read
      >
      > before you call the to_xexpr function?
      >
      > </F>
      >
      >
      >[/color]

      Comment

      Working...