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
Always save the .py file to disk next to the .ipynb #1060
Comments
Similar to the discussion about ipynbo files, I'd be wary of creating extra files in the working directory by default. But I agree that there should be an easy way to make importable .py files. |
Sorry. Wrong button. |
I think this idea is worth thinking about as we really do want the notebooks to be usable for more "library" style code. But I do worry about what @takluyver brought up about adding extra files to the working directory. We would have to be very careful about not overwriting existing .py files a user has. Are there other ways we could enable this type of library mode. But the implementation of this idea should not be too difficult if we want it on always. Making it configurable from the notebook Ui would add a bit of work. Making it configurable using the regular IPythyon config system would not be too bad. |
yes, implementing this, especially if it's server-configurable or not configurable should be very easy (~2 extra lines in the save routine). I do really worry about clutter, but at the same time this could be quite useful. I know that for my work, if every IPython notebook created 4 separate files next to each other (currently proposed: ipynb, ipynbo, autosaved backup, python script), I would be very angry. That level of clutter is just not acceptable. We should consider the cost of adding unrequested files in the working dir very high indeed. Just like @takluyver recommended using something akin to the Another thing we should probably do, regardless of where we come down on this - support Of course, since I would imagine this to be a minority use case (if not an uncommon one), if putting the script adjacent to the notebook is off by default, I wouldn't object to that being the behavior. |
I agree with @minrk 's comments about not wanting to clutter the On Mon, Nov 28, 2011 at 3:44 PM, Min RK
One option would be to create a visible subdirectory for all of the
Having such a cache for the .py files also makes it difficult to
Yep, doing that won't be too difficult.
I agree it should be off by default, but I guess I am not quite
Brian E. Granger |
On Mon, Nov 28, 2011 at 3:42 AM, Robert Kern
Yes, we should certainly have a command-line form of this. Note that |
On Mon, Nov 28, 2011 at 3:19 PM, Brian E. Granger
The clutter issue is indeed a problem, and this should certainly never
also because that would force us to reimplement a fair amount of machinery.
I think that going with just our config system for now is perfectly |
On Mon, Nov 28, 2011 at 3:44 PM, Min RK
I think the .py files have a stronger justification for being put next
Yes, that's why I don't like much the idea of putting them elsewhere;
That, I completely agree on. |
On Mon, Nov 28, 2011 at 7:15 PM, Brian E. Granger
I still haven't really been able to find a way that makes import
I'd certainly love to find a solution that makes everyone happy, since |
I think what's probably best, if we want to do anything magic, is just save the script in a special location that IPython has prepended to sys.path, just like we do with extensions. Anything more complicated than that may not be worth it. |
Writing a http://www.python.org/dev/peps/pep-0302/ |
We could potentially save .py files in a subdirectory from the pwd called I think the bigger issue is that we need a good settings panel in the |
On Tue, Nov 29, 2011 at 2:17 AM, Robert Kern
I'd thought about that (Ilan told me about these guys, which I didn't With an import hook, we'd probably want to create I'd love to be proven wrong, but every time I look at this, any |
I don't think we should do anything on this front yet. We have a lot of redesigning of the notebook coming up and that will give us a chance to think about this further. |
I just realized that we should probably close this issue. We now have the |
Closing now; we can open a new one later if we want fancier featuers, but for now the simple |
The more I think about it, the more it seems to me that we should always write the .py file next to the notebook. This would let more library-like uses of the code in a much easier workflow than now (where one must go through the download button, that puts the files in a different place, etc). Furthermore, by putting at the top:
one could then write the 'script parts' of the notebook with
and the notebook could then be 'imported'. Since it would be a normal .py file, it would make it much easier to reuse code from one notebook to another via normal import mechanisms.
We may want later to consider other forms of cross-notebook referencing and loading, but I think that having out of the box mechanism to reuse notebooks as normal libraries would be extremely valuable.
@ellisonbg, @minrk, do you think it's easy to add a flag to do this automatically? I'd vote for having it always on, but I guess one could also want to turn it off, case in which it would need to be configurable. Ideally per-notebook, stored in the metadata, but initially it could be a server-level flag stored in the config file.
The text was updated successfully, but these errors were encountered: