On Thu, 13 Nov 2014 11:33:22 -0800 (PST) Phil <phil.s....@gmail.com> wrote:
> > > > > Yes, that works. I don't understand why though - the current > > > path - "." - is still Y, isn't it? How does that make it possible > > > for A to find B? > > > > I think the current directory is wherever A is, check > > > > import os > > g.es(os.getcwd()) > > > > in A > > > > But I think Python doesn't try to import from the current directory > > unless you specifically tell it to, as above. > > > > > A couple experiments helped me to understand. In fact, Leo *does* > execute a script in the path designated by @path, but as you pointed > out, the Python search path does not include that path by default. > However, this is different behavior from executing a script directly > from a command prompt, in which case the default search path *does* > include the current directory. > > I would prefer not having to explicitly add the current path. Can > this behavior be captured in Leo's code that executes the script? sys.path.insert(0,c.frame.openDirectory) occurs in .../leo/core/LeoPyRef.leo#Code-->Core classes-->@file leoCommands.py-->class Commands-->c.Command handlers...-->Edit Menu...-->Edit top level-->c.executeScript & helpers so presumably sys.path.insert(0, '.') could go there as well. There's a finally: clause not long after that that deletes sys.path[0], that would need to remove '.' as well (at least to stop sys.path growing all the time). Deleting sys.path[0] assumes the script didn't mess with sys.path, maybe it would be better to copy / restore it. Anyway, this is core enough for me to want Edward to weigh in - you reading this, Edward? Cheers -Terry > Phil > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.