-
Notifications
You must be signed in to change notification settings - Fork 0
make %%writefile work w pshnb #6
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
base: main
Are you sure you want to change the base?
Conversation
from IPython.paths import get_ipython_dir | ||
from IPython.core.interactiveshell import InteractiveShell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed some unused imports
@@ -118,11 +114,23 @@ def bash(self, line, cell=None): | |||
raise e from None | |||
if disp and res: print(res) | |||
|
|||
@magic_arguments() | |||
@argument('-a', '--append', action='store_true', help='Append contents of the cell to an existing file. The file will be created if it does not exist.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same args as the original %%writefile
Thanks @RensDimmendaal ! I just added: 4693623 . With this change, it is now quite easy to ensure that the bash interpreter directory is synchronized with Python's current directory, and you could do this before you run writefile. This way you have the choice as to whether you want to write a file to the current Python or current shell directory. Also, to write to the current shell directory, you can simply use normal bash cat and heredoc. I'm thinking we should leave it that way rather than shadowing the writefile magic. I'm a bit nervous that shadowing the right file magic might also cause some kind of strange bugs which I am having trouble thinking about but feel like they could get confusing. wdyt? |
Whoah! Smart! More concise and more robust. We could take this one step further:
Then:
|
%%writefile is a built-in magic that we can now also make aware of the pshnb workdir. This PR makes that possible.