[Bf-python] python relative imports

Domino Marama domino at dominodesigns.info
Sat Sep 3 00:47:34 CEST 2011


On Sat, 2011-09-03 at 06:34 +0800, HartsAntler wrote:
> Hi Vaclav,
> I was having the same problem, this can fix it.
> 
> 
> ## make sure we can import from same directory ##
> SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
> if SCRIPT_DIR not in sys.path: sys.path.append( SCRIPT_DIR )
> 

You can also use

from . import dxfLibrary as DXF

and if you just want an odd function

from .dxfLibrary import oddFunction

> 
> On Fri, Sep 2, 2011 at 3:31 PM, Vaclav Klecanda <vencax77 at gmail.com>
> wrote:

>         In migiusModel I would like import dxfLibrary:
>         
>         
>         try:
>             import dxfLibrary as DXF
>         except Exception:
>             raise Exception("No dxfLibrary.py module")
>         
>         
>         but I get the exception ...
>         






More information about the Bf-python mailing list