Dyalog / pynapl

Dyalog APL ←→ Python interface
MIT License
74 stars 10 forks source link

Add current directory to default module load path? #3

Closed jayfoad closed 5 years ago

jayfoad commented 5 years ago

When you import a module, Python looks for it in the directories listed in sys.path (loads more info here). The first thing on sys.path is the directory containing the input script, or '' (i.e. the current working directory) if there was no input script, i.e. for normal interactive use, so you can import stuff straight from the cwd.

I reckon that folks using pynapl to call Python from APL would see it as interactive use, and would like to be able to import stuff from the cwd. Unfortunately that doesn't work at the moment because under the covers Python is started with an input script, so sys.path does not start with ''.

I reckon we should explicitly add '' to sys.path at startup, so that import works as users expect.