On Friday, January 27, 2017 at 1:34:08 PM UTC+1, Almar Klein wrote: > What happens in Pyzo if you do as that post says? > > > From: dietrich....@microgate.it > Sent: 27 January 2017 12:34 > To: Pyzo > Cc: dit...@gmail.com > Subject: Re: [Pyzo] how to execute python magics from script > > On Tuesday, October 25, 2016 at 10:40:40 AM UTC+2, Almar Klein wrote: > > Ok, we can have a go at this. Any code like this should be added in > > pyzo/pyzokernel. I guess the main code is best put in a new module, which > > is then used in interpreter.py (where the entry points for executing a file > > are). > > > > I am wary of forcing a reload for each module in the user directory. Maybe > > we can keep track of the file’s modified times to only reload those that > > changed? Let’s make a start and see how it goes. > > > > - Almar > > > > > > > > From: Dietrich Pescoller > > Sent: 17 October 2016 18:09 > > To: Pyzo > > Cc: dit...@gmail.com > > Subject: Re: [Pyzo] how to execute python magics from script > > > > > > Hmm have you ever used Spyder? > > The module auto loading works very well there. > > > > 1) Initially i started using Pyzo (when it both a python distro and an > > editor) > > > > 2) then I switched to Spyder, because of the module reloading problem. The > > Spyder UMR (User Module Reloader) works quite well and is something needed > > when you do scientific computaton > > where you typicallycan not always restart the shell but you are > > continuously adapting, updating and changing your functions > > > > 3) than I switched back to IEP, because on the other side the debugging in > > Spyder is very uncomfortable. > > > > Now since both Spyder and IEP are just editors (which I find good) one can > > switch easily between the two depending on what is more important. But of > > course one would prefer to use > > always the same tool. And in my opinion (having used both as a scientific > > user) personally I thing IEP is perhaps the better solution. > > > > Some feature are already present in the ipython shell like the autoreload, > > and this was basically the rationale behind my question. > > > > Perhaps IEP could implement the UMR as well? If you look at how it is > > implemented in Spyder it is something quite simple: > > https://github.com/spyder-ide/spyder/blob/master/spyder/utils/site/sitecustomize.py > > I could contribute in this but I'm still missing the whole picture of the > > pyzo code. So I would have big difficulties to know where to put similar > > code. > > > > Or perhaps there are other ways to achieve the same result don't know. > > > > Bye, > > Dietrich > > > > > > > > > > > > > > > > > > > > > > > > Il giorno sabato 8 ottobre 2016 17:56:09 UTC+2, Almar Klein ha scritto: > > > > > > > 1) run/call a script from another script > > > > code = open(filename, ‘rb’).read().decode() > > exec(code) # look at the docs of exec for possible extra arguments > > > > > make python use changes when you edit a file > > > > This is not trivial; it would require a lot more than 2 lines :) though > > maybe there is a lib for that? > > > > The workflow in Pyzo would be to select a file as main file, so that you > > can execute it while working on another file, and the run the main file > > using Run > run main file as script, or better yet, use Ctrl+Shift+E. > > Running as script is important because it will restart the shell and use > > the latest version of all modules. > > > > Regards, > > Almar > > > > > > > > From: Dietrich Pescoller > > Sent: 07 October 2016 14:54 > > To: Pyzo > > Cc: dit...@gmail.com > > Subject: Re: [Pyzo] how to execute python magics from script > > > > > > Is there another way to obtain the same result in python without using > > magics? > > There are many use cases but at least I would like to be able at least to: > > 1) run/call a script from another script > > this is achieved in ipython with %run -i myFile.py > > 2) make python use changes when you edit a file > > this is achieved in ipython by calling > > > > % load_ext autoreload > > % autoreload 2 > > > > Thanks, > > Dietrich > > > > > > Il giorno martedì 27 settembre 2016 21:52:22 UTC+2, Almar Klein ha scritto: > > > > > > No, its not possible to use magics in the script. This is deliberate, since > > it would be invalid Python. Not sure why the use of the ipython API calls > > would not work. Pyzo’s IPython shell is not completely a proper IPython > > shell, so it might be that we don’t do enough for this to be picked up > > somehow… > > > > What is the problem that you’re trying to fix, or workflow that you’re > > trying to achieve? Maybe there are other ways to make it work. > > > > - Almar > > > > > > > > > > From: Dietrich Pescoller > > Sent: 27 September 2016 18:22 > > To: Pyzo > > Subject: [Pyzo] how to execute python magics from script > > > > > > Is there a way to execute ipython magics from script in IEP. > > In particular I'm interested in startup script > > > > I tired something like this: > > from IPython import get_ipython > > get_ipython().magic('load_ext autoreload') > > get_ipython().magic('autoreload 2') > > > > Which works in a standard ipython console but does not work when using IEP. > > > > > > Any suggestion would be apprecieated > > > > Thanks, > > Dietrich > > -- > > You received this message because you are subscribed to the Google Groups > > "Pyzo" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to pyzo+uns...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Pyzo" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to pyzo+uns...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Pyzo" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to pyzo+uns...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > > > Hi I did some experimenting on this. > I noticed that UMR is not as powerful as %autoreload. > Could this be a possible way? > https://www.keybits.net/post/configure-autoreload-for-ipython/ > How to integrate it in IEP? > > -- > You received this message because you are subscribed to the Google Groups > "Pyzo" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pyzo+uns...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. >
... continuning working finally I got it to working... the solution was easy maybe you did not really got what I was looking for. 1) I put %load_ext autoreload %autoreload 2 in the "Code to run at startup" section of the shell configuration (there the magics are working/accepted) 2) I added a way to run the script as "run -i" see https://github.com/pyzo/pyzo/compare/master...Diti24:patch-1 It would be nice to consider these too as a simple option for the user and become part of IEP -- You received this message because you are subscribed to the Google Groups "Pyzo" group. To unsubscribe from this group and stop receiving emails from it, send an email to pyzo+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.