Hi Carlos, Thanks! I will check out the relative import solution. (I should try to see what are the best practices). Regarding the working directory, I have to wait for Monday to have the environment where I can reproduce the behaviour. Best
On Saturday, June 8, 2013 11:14:55 AM UTC-4, Carlos Córdoba wrote: > > Hi Sylvain, > > Two things: > > 1. If the working directory of module_test.py is not correctly taken to be > "project" (after you set it to be it with the "Run settings" dialog) then > that's a bug and you need to open an issue for it. > > 2. You could use relative imports to deal more easily with this situation. > So a simple: > > from .module import foo > > in module_test.py should be enough. The advantage of this approach (of > course) is that it doesn't depend on Spyder to run correctly. > > Cheers, > Carlos > > El 07/06/13 19:09, Sylvain Corlay escribió: > > Hello everyone: > > If i am in the following situation > > project/ > package/ > module.py > module_test.py > > where module.py contains a function foo to be tested in module_test.py. > > *Case one: *the default working directory for module_test.py is > project/package > Then I should do in module_test.py > # module_test.py > from module import foo > > This works perfectly, but if I run the same code in an ipython console, > in the project directory, I get an import error. The correct way to import > foo would then be > >> from package.module import foo > > *Case two: *Then a good practice in spyder would be to write > # module_test.py > from package.module import foo > in module_test.py, and configure the default working directory of > module_test.py to be "project", so that the same code will work in both > situations. (Using run selection or runfile). > > However, it seems that the spyder does not take into account the working > directory of "Run settings" but only the default working directory of the > preference dialog. > > Is it a bug or am I missing something? > > Cheers, > > Sylvain > -- > You received this message because you are subscribed to the Google Groups > "spyder" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > To post to this group, send email to [email protected]<javascript:> > . > Visit this group at http://groups.google.com/group/spyderlib?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > > > -- You received this message because you are subscribed to the Google Groups "spyder" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/spyderlib?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
