-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Added option to use magic in .py files #280
base: master
Are you sure you want to change the base?
Conversation
Hey @pinguicula, thanks for your contribution. Could you explain us what you're trying to achieve with these changes? |
Hi @ccordoba12 and thanks for your quick answer ! Sometime when I debug .py files I want to be able to use magic and flexible indentation. With this change, the user have the option to allow .py-files to be treated in the same way as .ipy files. (When I say debug, I mean that I run the code cell by cell in spyder). I appreciate your motivation that all .py files should be able to execute outside of spyder but this gives the user the option (note, completely optional) to debug .py files as if they were .ipy. My current change is not very intrusive but I am thinking that this could possibly be changed to something in the GUI: a checkbox or list of file extensions that are treated as .py. Thanks for considering this. |
Yep, I was thinking exactly that because perhaps only you and us would be the only ones aware of this possibility. @impact27, what do you think about this? |
I think magic are only valid in .ipy files, because if you use magics in your file, then it is not a python file, but a ipython file. You can just rename your file (file.py -> file.ipy), unless you have a usecase where this is not possible? |
I am using spyder in my workflow for development of .py files. I use cells very frequently. Running cells are interpreted as flexible indentation which means spyder think that they are magic. Example:
|
I am not sure I follow:
runs fine for me both in spyder and with python3.
A magic would be for example: |
Cells are sometimes interpreted as flexible indentation which spyder thinks are magic. |
Do you have an example of code that would do that? |
I am afraid not. I think it is a bug and it can appear suddenly and then disappear again after restarting the kernel. In any case, since I am using an IPython interpreter while I am in spyder, I would like to be able to use magic. Personally, patching spyder is sufficient, but I am sure that I am not the only one with this setup and issue. |
If you can reproduce I would be interested to see the code that triggers this behaviour. Usually I would just use the console to write magics. I never had a problem running cells separated by |
No description provided.