absolute imports (python-2.5)

Discussion in 'Python' started by jUrner@arcor.de, Aug 29, 2006.

  1. Guest

    Hello all

    I just played around a bit with python 2.5 and relative imports.
    Bit disappointed so far. Hoped to be able to use this new feature
    to develop standalone libraries that can be just dropped into
    any project without having to adjust any imports.

    pkg/
    pkg/__init__.py
    pkg/main.py
    pkg/string.py


    "main.py" does:
    from . import string

    no problem if you import the whole package from another module:
    import pkg

    but if you execute "main.py" you get an error
    "ValueError: Relative importpath too deep"

    This is looks a nightmare come true for developing modules.
    I read all available information regarding the "-m" switch and its
    limitations when it comes to relative imports. Being impatient
    and scarend of having to wait another (year!) for this feature to
    become usable I wonder if anyone has any better information on
    things ahead.

    Juergen
     
    , Aug 29, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Cooper

    Absolute Imports and PYTHONPATH

    Richard Cooper, May 5, 2004, in forum: Python
    Replies:
    1
    Views:
    616
    John Roth
    May 6, 2004
  2. Albert
    Replies:
    4
    Views:
    11,689
    Albert
    Jul 10, 2008
  3. Steven D'Aprano

    Absolute imports in Python 2.4

    Steven D'Aprano, Jun 2, 2009, in forum: Python
    Replies:
    2
    Views:
    1,182
    Steven D'Aprano
    Jun 4, 2009
  4. Roy Smith

    Absolute imports?

    Roy Smith, Jan 8, 2011, in forum: Python
    Replies:
    5
    Views:
    357
    Jean-Michel Pichavant
    Jan 10, 2011
  5. zildjohn01
    Replies:
    0
    Views:
    897
    zildjohn01
    Feb 22, 2011
  6. Michael Parker

    Forcing absolute package imports in 2.7?

    Michael Parker, Mar 31, 2011, in forum: Python
    Replies:
    1
    Views:
    688
  7. Gelonida N
    Replies:
    0
    Views:
    295
    Gelonida N
    Sep 7, 2012
  8. Victor Hooi
    Replies:
    1
    Views:
    310
    Devin Jeanpierre
    Nov 25, 2013
Loading...