New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add directory for startup files #950
Conversation
Looks great, thanks! I'd like to have a test in the suite for this though: a simple temp-generated file with Once we get a test, good to go. Great work, this will be really liked by users. |
I don't quite know how to write that test, but I'll figure it out. I think I need to copy a lot of the env code from test_path. |
Great, thanks. Let me know if you get stuck and I can pitch in. |
test added (and fixed a small bug in ipexec_validate, which was needed) |
Mmh, the check for the startup files/directory must be optional. Right now, IPython won't even start if those files aren't there:
Having those files and directories should be completely optional... Furthermore, it looks like you forgot to commit the README file itself, I think. |
The bug is the new readme missing from git. IPython creates any missing dirs, so it doesn't matter if you make them or remove them, it will always run just fine. The readme is entirely pointless if IPython doesn't create the dir. On Oct 30, 2011, at 17:09, Fernando Perezreply@reply.github.com wrote:
|
Any .py or .ipy file in this directory will be run at startup. Files are run in in lexicographical order, as described in ipython#914
more profile tests should be added to this file
Missing readme added to git. You absolutely don't have to create the dir yourself, IPython will do it for you (just like log, security, pid), and stage the README into it. |
Looks great now, thanks! Merging... |
Add directory for startup files, enabling users to add local configuration more simply without having to know how the config system works much at all. Now, `profile/startup` dir is checked for files, and they are run prior to explicit exec_code and exec_files. A short README is added to the dir explaining how they work, and a short paragraph is added to the docs, in both the interactive tutorial and config overview.
awesome, thanks! |
Hi, However, I can use
and then the module is available in the shell Was this behavioral difference intentional ? |
I don't think that was intentional. Does it affect all import, or just |
Good point ! Indeed I've just checked that for instance I don't know the internal machinery behind future imports though. I just noticed that there is a complain if the future import statement is not the first one in the file. But I guess it's the same for any Python script. Is it ? |
Yes, I think that's the same for any Python file. OK, the problem is that startup files are run by ip.safe_execfile() |
I've checked that indeed using the .ipy extension makes future imports work. Thanks for the tip. I feel like this issue is too small to deserve a bug report but I think it should be fixed at some point. In the meantime, my suggestion is to add a footnote in the README in the startup directory that would explain: 1) the problem 2) the solution you mentioned (using .ipy instead of .py). I propose something like this : About importing modules : using import statements in startup .py files will make the imported modules available in the running ipython session. This is one of the useful uses of startup scripts. What do you think ? |
It may require a note in the documentation, depending on what we decide to do. On reflection, though, using .ipy is a rather ugly hack, and we might decide that it shouldn't work from .ipy files either. A better workaround is to call The tricky thing is working out what semantics people expect. If your So, where can IPython run interactive code that we need to consider:
My gut feeling is that of those, |
Add directory for startup files, enabling users to add local configuration more simply without having to know how the config system works much at all. Now, `profile/startup` dir is checked for files, and they are run prior to explicit exec_code and exec_files. A short README is added to the dir explaining how they work, and a short paragraph is added to the docs, in both the interactive tutorial and config overview.
profile/startup dir is checked for files, and they are run prior to explicit exec_code and exec_files.
a short README is added to the dir explaining how they work, and a short paragraph is added to the docs, in both the interactive tutorial and config overview.
closes #914