[Pyzo] Re: Run File (Interactive mode) changes the working directory

2017-07-04 Thread Dietrich Pescoller
In your scenario wouldn't it be better to put your root folder to python's 
path?
I find the rule of change directory before running a script very useful and 
more strightforward...
... anyway to have a configurable option will be the best solution for this.

Bye,
diti

Il giorno lunedì 3 luglio 2017 10:11:53 UTC+2, Ido Dayan ha scritto:
>
> בתאריך יום שני, 3 ביולי 2017 בשעה 10:38:17 UTC+3, מאת Ido Dayan: 
> > Hello 
> > 
> > I've installed Pyzo 4.4.0 for windows and when I use "Run File" the CWD 
> is changed to the file's directory. 
> > 
> > How to prevent that ? 
> > 
> > Ido 
>
> Thanks Almar. 
>
> 1. This change is not yet updated in the pyzo web site: 
> http://www.pyzo.org/interactive_vs_script.html 
>
> 2. My use case is: 
> I have a package pkg1 in /pkg1 with modules m1.py m2.py ... 
> when my WD is set to  I can write in m1.py : 
> import pkg1 
> or 
> import pkg1.m2 
>
> But now, when the WD is automatically changed into pkg1 - these lines 
> don't work. 
>
> Thanks, Ido.

-- 
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.


Re: [Pyzo] how to execute python magics from script

2017-01-30 Thread dietrich . pescoller
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:
> &

Re: [Pyzo] Ipython autocompletion

2016-12-19 Thread dietrich . pescoller
On Monday, December 19, 2016 at 10:43:02 AM UTC+1, Almar Klein wrote:
> Although IPython can be integrated with Pyzo’s shell, they use a different 
> autocompletion mechanism.
>  
> 
> From: dietrich@microgate.it
> Sent: 16 December 2016 15:29
> To: Pyzo
> Subject: [Pyzo] Ipython autocompletion
>  
> Is there a way to make the autocompletion work in pyzo like in ipython?
> I tried the command:
> %config IPCompleter.greedy=True
>  
> as suggested in this post
> http://stackoverflow.com/questions/33498591/ipython-autocompletion-for-list-or-dict-of-objects
>  but unfortunately it does not work in pyzo. However it works in ipython just 
> as expected and is very usefu.
>  
> Bye,
> 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.
>  

Understood.
Is there a way to have dictonary (or named array) autocompletion as well under 
pyzo? Or similarly for h5py files autocompletion?

-- 
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.


Re: [Pyzo] Strange behavior in console history

2016-10-11 Thread Dietrich Pescoller
Thanks
Dietrich

Il giorno martedì 11 ottobre 2016 11:00:38 UTC+2, Almar Klein ha scritto:
>
> There already is an issue for it. And now wrote it on my personal todo 
> list. Might be a few weeks before I get to it though.
>
>  
>
> https://github.com/pyzo/pyzo/issues/248
>
>  
>
>  
>
>  
>
> *From: *Dietrich Pescoller 
> *Sent: *10 October 2016 14:39
> *To: *Pyzo 
> *Cc: *dit...@gmail.com 
> *Subject: *Re: [Pyzo] Strange behavior in console history
>
>  
>
> Ok,
> was thinking there is just a simple line/command to type...
>
> Anyway, do you thing this is something which will be fixed soon? So should 
> we just wait and be patient, or should we try to find a way to leave with 
> this issue?
>
> Thanks,
> Dietrich
>
> Il giorno lunedì 10 ottobre 2016 11:23:00 UTC+2, Almar Klein ha scritto:
>
> That’s probably possible. But typing that code into the logger shell each 
> time would be tedious. So you’d have to modify the Pyzo source code.
>
>  
>
>  
>
> *From: *Dietrich Pescoller
> *Sent: *10 October 2016 09:23
> *To: *Pyzo
> *Cc: *dit...@gmail.com
> *Subject: *Re: [Pyzo] Strange behavior in console history
>
>  
>
> Is there perhaps a temporary manual workaround for this? For instance to 
> load the history tool entries into console?
> This would be already be very useful
>
> Thanks,
> Dietrich
>
> Il giorno sabato 24 settembre 2016 14:26:14 UTC+2, Almar Klein ha scritto:
>
> I think both tools keep track of history separately from each other. While 
> the tool preserves it between sessions, the shell’s own history does not. 
> There is an issue to fix the latter.
>
>  
>
>  
>
>  
>
> *From: *Dietrich Pescoller
> *Sent: *23 September 2016 15:44
> *To: *Pyzo
> *Subject: *[Pyzo] Strange behavior in console history
>
>  
>
> Do some one else have strange behaviors in the Ipython console History 
> using pyzo?
>
> The history viewer seems to work properly, ie.. if you issue a new command 
> it updates the history.
>
> If you restart the shell, if you use UP and Down arrow the commands do not 
> appear.
> If you issue a new command and do not restart the shell the arrow work for 
> that command.
>
> It is strange because the history viewer contains typically all the 
> commands from older sessions... but those are not recallable from the 
> Ipython-console
>
> 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.
>
>  
>

-- 
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.


Re: [Pyzo] IEP and __file__

2016-10-11 Thread Dietrich Pescoller
Ok I see your point. I did the following further tests:

I have the prova.py file containing print(__file__)

and did the following with 
 ~/anaconda3/bin/python
with open("/tmp/prova.py") as f:
   code = compile(f.read(), "/tmp/prova.py", 'exec')
   exec(code)

and got
/tmp/prova.py in ()
> 1 print(__file__)

NameError: name '__file__' is not defined

Than I did 
 ~/anaconda3/bin/ipython
In [1]: %run /tmp/prova.py
/tmp/prova.py

So should pyzo be more "compatible/similar" to python or ipython?

IMO since pyzo is more a Scientifice IDE, (ala Matlab) probably it should 
be more "compatible/similar" to ipython than pure python.
Probably sometimes pragmaticity should be preferred to purity.

But this is only my personal opinion, I fully understand your point and I m 
not the person who can say which one is the better one. Probably this 
should become a more
general discussion with more people involved.

Anyway, probably the best  is to let the things like they are, unless other 
people or other arguments come up to support my way.

Thanks,
Dietrich








Il giorno martedì 11 ottobre 2016 10:52:36 UTC+2, Almar Klein ha scritto:
>
> > wouldn't it be the best/easiest solution or simply set the __file__ 
> variable as the standard behavior?
>
>  
>
> Well, if you’d first run a file as a script (which would set __file__), 
> and then run another file (not as a script) then the __file__ would be 
> overwritten, which would be wrong, IMO; __file__ should maintain the value 
> of the script that was initially run.
>
>  
>
> > __file__ is only present when running a file as script. Similar to how 
> there is no __file__ in the normal Python interpreter
>
>  
>
> I mean that there is no __file__ when you run the Python interpreter 
> interactively, without running a script. In your example you do run a 
> ascript. Try:
>
>  
>
> $ python
>
> >> __file__
>
> Traceback (most recent call last):
>
>   File "", line 1, in 
>
> NameError: name '__file__' is not defined
>
>  
>
>
>
>  
>
> *From: *Dietrich Pescoller 
> *Sent: *10 October 2016 14:36
> *To: *Pyzo 
> *Cc: *dit...@gmail.com ; proj...@gmail.com 
> *Subject: *Re: [Pyzo] IEP and __file__
>
>  
>
> In your suggestion the only drawback is that 'foo.py' needs to be set 
> manually, This would work and is acceptable but of course not optimal.
>
> I can understand you point to not add another way to run a file.
> My question/thought since in the current file execution (command) the 
> __file__ is not set and thus typically is not used, wouldn't it be the 
> best/easiest
> solution or simply set the __file__ variable as the standard behavior?
>
> Btw you wrote in a prevoius mail: """__file__ is only present when running 
> a file as script. Similar to how 
> there is no __file__ in the normal Python interpreter. """
>
> I'm not sure this is correct since I thing that the standard python 
> interpreter actually defines the __file__variable.
>
> I did worte prova.py with the following simple code:
> print(__file__)
>
> and obtained both with ipython and python the same result:
>
> diti$ ~/anaconda3/bin/ipython /tmp/prova.py 
> /tmp/prova.py
> diti$ ~/anaconda3/bin/python /tmp/prova.py 
> /tmp/prova.py
>
> Thanks,
> Dietrich
>
> Il giorno lunedì 10 ottobre 2016 11:26:13 UTC+2, Almar Klein ha scritto:
>
> I am hesitant to add yet another way to run a file. Since the current 
> directory is changed now, would it work for you to put this at the top of 
> your file:
>
>  
>
> __file__ = os.path.join(os.cwd(), ‘foo.py’)
>
>  
>
> *From: *Dietrich Pescoller
> *Sent: *10 October 2016 09:20
> *To: *Pyzo
> *Cc: *dit...@gmail.com; proj...@gmail.com
> *Subject: *Re: [Pyzo] IEP and __file__
>
>  
>
> Yes, but also in this case if I run the file as a script than the console 
> is retarted and we loose all previous work.
> Effectively we are in a very same situation as we had with the current 
> directory setting.
>
> Perhaps could it be the definitive solution to have the option "running as 
> a script" not restarting the shell? If this is needed the user can do it 
> very easily manually, or perhaps having a third option, i.e. run as a 
> script (with all the special settings __file__ setting directory,) but not 
> automatically restarting. (just a thought)
>
> Finally I not really need to use __file__ I would just need to find out 
> another way to get the current filename.
>
> Thanks,
> Dietrich
>
> Il giorno sabato 8 ottobre 2016 22:02:29 UTC+2, Almar Klein ha scritto:
>
> Run the file as a script.
>
>  
>
> Runni

Re: [Pyzo] Strange behavior in console history

2016-10-10 Thread Dietrich Pescoller
Ok,
was thinking there is just a simple line/command to type...

Anyway, do you thing this is something which will be fixed soon? So should 
we just wait and be patient, or should we try to find a way to leave with 
this issue?

Thanks,
Dietrich

Il giorno lunedì 10 ottobre 2016 11:23:00 UTC+2, Almar Klein ha scritto:
>
> That’s probably possible. But typing that code into the logger shell each 
> time would be tedious. So you’d have to modify the Pyzo source code.
>
>  
>
>  
>
> *From: *Dietrich Pescoller 
> *Sent: *10 October 2016 09:23
> *To: *Pyzo 
> *Cc: *dit...@gmail.com 
> *Subject: *Re: [Pyzo] Strange behavior in console history
>
>  
>
> Is there perhaps a temporary manual workaround for this? For instance to 
> load the history tool entries into console?
> This would be already be very useful
>
> Thanks,
> Dietrich
>
> Il giorno sabato 24 settembre 2016 14:26:14 UTC+2, Almar Klein ha scritto:
>
> I think both tools keep track of history separately from each other. While 
> the tool preserves it between sessions, the shell’s own history does not. 
> There is an issue to fix the latter.
>
>  
>
>  
>
>  
>
> *From: *Dietrich Pescoller
> *Sent: *23 September 2016 15:44
> *To: *Pyzo
> *Subject: *[Pyzo] Strange behavior in console history
>
>  
>
> Do some one else have strange behaviors in the Ipython console History 
> using pyzo?
>
> The history viewer seems to work properly, ie.. if you issue a new command 
> it updates the history.
>
> If you restart the shell, if you use UP and Down arrow the commands do not 
> appear.
> If you issue a new command and do not restart the shell the arrow work for 
> that command.
>
> It is strange because the history viewer contains typically all the 
> commands from older sessions... but those are not recallable from the 
> Ipython-console
>
> 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Pyzo] IEP and __file__

2016-10-10 Thread Dietrich Pescoller
In your suggestion the only drawback is that 'foo.py' needs to be set 
manually, This would work and is acceptable but of course not optimal.

I can understand you point to not add another way to run a file.
My question/thought since in the current file execution (command) the 
__file__ is not set and thus typically is not used, wouldn't it be the 
best/easiest
solution or simply set the __file__ variable as the standard behavior?

Btw you wrote in a prevoius mail: """__file__ is only present when running 
a file as script. Similar to how 
there is no __file__ in the normal Python interpreter. """

I'm not sure this is correct since I thing that the standard python 
interpreter actually defines the __file__variable.

I did worte prova.py with the following simple code:
print(__file__)

and obtained both with ipython and python the same result:

diti$ ~/anaconda3/bin/ipython /tmp/prova.py 
/tmp/prova.py
diti$ ~/anaconda3/bin/python /tmp/prova.py 
/tmp/prova.py

Thanks,
Dietrich

Il giorno lunedì 10 ottobre 2016 11:26:13 UTC+2, Almar Klein ha scritto:
>
> I am hesitant to add yet another way to run a file. Since the current 
> directory is changed now, would it work for you to put this at the top of 
> your file:
>
>  
>
> __file__ = os.path.join(os.cwd(), ‘foo.py’)
>
>  
>
> *From: *Dietrich Pescoller 
> *Sent: *10 October 2016 09:20
> *To: *Pyzo 
> *Cc: *dit...@gmail.com ; proj...@gmail.com 
> *Subject: *Re: [Pyzo] IEP and __file__
>
>  
>
> Yes, but also in this case if I run the file as a script than the console 
> is retarted and we loose all previous work.
> Effectively we are in a very same situation as we had with the current 
> directory setting.
>
> Perhaps could it be the definitive solution to have the option "running as 
> a script" not restarting the shell? If this is needed the user can do it 
> very easily manually, or perhaps having a third option, i.e. run as a 
> script (with all the special settings __file__ setting directory,) but not 
> automatically restarting. (just a thought)
>
> Finally I not really need to use __file__ I would just need to find out 
> another way to get the current filename.
>
> Thanks,
> Dietrich
>
> Il giorno sabato 8 ottobre 2016 22:02:29 UTC+2, Almar Klein ha scritto:
>
> Run the file as a script.
>
>  
>
> Running code normally (not as a script) is equivalent to firing up having 
> a Python interpreter and running code in it. There is no script file, and 
> thus no __file__. Technically, Pyzo could set __file__ each time a file is 
> run, but it would be wrong to reset that variable.
>
>  
>
> I recently made a change to set the current directory when a file is run 
> also if its *not* run as a script. In this case practicality beats purity, 
> plus the current directory is expected to be more dynamic than the value of 
> __file__.
>
>  
>
> - Almar
>
>  
>
>  
>
>  
>
> *From: *Dietrich Pescoller
> *Sent: *07 October 2016 16:41
> *To: *Pyzo
> *Cc: *proj...@gmail.com
> *Subject: *Re: [Pyzo] IEP and __file__
>
>  
>
> I had the same issue recently.
> What would be the best way in a script to get its own filename than?
>
> Thanks,
> Dietrich
>
>
>
> Il giorno martedì 13 ottobre 2015 22:32:24 UTC+2, Almar Klein ha scritto:
>
> __file__ is only present when running a file as script. Similar to how 
> there is no __file__ in the normal Python interpreter. 
>
> - Almar 
>
> On 13-10-15 22:08, Christophe Bal wrote: 
> > Hello. 
> > 
> > It seems that I can't use directly __file__. Is it normal or is it a bug 
> > ? If it's normal what is the technical reason for that ? 
> > 
> > 
> > *Christophe BAL* 
> > *Enseignant de mathématiques en Lycée **et développeur Python amateur* 
> > *---* 
> > *French math teacher in a "Lycée" **and **Python **amateur developer* 
> > 
> > -- 
> > 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 
> > <mailto: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.
>
>  
>

-- 
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.


Re: [Pyzo] IEP and __file__

2016-10-10 Thread Dietrich Pescoller
Yes, but also in this case if I run the file as a script than the console 
is retarted and we loose all previous work.
Effectively we are in a very same situation as we had with the current 
directory setting.

Perhaps could it be the definitive solution to have the option "running as 
a script" not restarting the shell? If this is needed the user can do it 
very easily manually, or perhaps having a third option, i.e. run as a 
script (with all the special settings __file__ setting directory,) but not 
automatically restarting. (just a thought)

Finally I not really need to use __file__ I would just need to find out 
another way to get the current filename.

Thanks,
Dietrich

Il giorno sabato 8 ottobre 2016 22:02:29 UTC+2, Almar Klein ha scritto:
>
> Run the file as a script.
>
>  
>
> Running code normally (not as a script) is equivalent to firing up having 
> a Python interpreter and running code in it. There is no script file, and 
> thus no __file__. Technically, Pyzo could set __file__ each time a file is 
> run, but it would be wrong to reset that variable.
>
>  
>
> I recently made a change to set the current directory when a file is run 
> also if its *not* run as a script. In this case practicality beats purity, 
> plus the current directory is expected to be more dynamic than the value of 
> __file__.
>
>  
>
> - Almar
>
>  
>
>  
>
>  
>
> *From: *Dietrich Pescoller 
> *Sent: *07 October 2016 16:41
> *To: *Pyzo 
> *Cc: *proj...@gmail.com 
> *Subject: *Re: [Pyzo] IEP and __file__
>
>  
>
> I had the same issue recently.
> What would be the best way in a script to get its own filename than?
>
> Thanks,
> Dietrich
>
>
>
> Il giorno martedì 13 ottobre 2015 22:32:24 UTC+2, Almar Klein ha scritto:
>
> __file__ is only present when running a file as script. Similar to how 
> there is no __file__ in the normal Python interpreter. 
>
> - Almar 
>
> On 13-10-15 22:08, Christophe Bal wrote: 
> > Hello. 
> > 
> > It seems that I can't use directly __file__. Is it normal or is it a bug 
> > ? If it's normal what is the technical reason for that ? 
> > 
> > 
> > *Christophe BAL* 
> > *Enseignant de mathématiques en Lycée **et développeur Python amateur* 
> > *---* 
> > *French math teacher in a "Lycée" **and **Python **amateur developer* 
> > 
> > -- 
> > 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 
> > <mailto: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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Pyzo] IEP and __file__

2016-10-07 Thread Dietrich Pescoller
I had the same issue recently.
What would be the best way in a script to get its own filename than?

Thanks,
Dietrich



Il giorno martedì 13 ottobre 2015 22:32:24 UTC+2, Almar Klein ha scritto:
>
> __file__ is only present when running a file as script. Similar to how 
> there is no __file__ in the normal Python interpreter. 
>
> - Almar 
>
> On 13-10-15 22:08, Christophe Bal wrote: 
> > Hello. 
> > 
> > It seems that I can't use directly __file__. Is it normal or is it a bug 
> > ? If it's normal what is the technical reason for that ? 
> > 
> > 
> > *Christophe BAL* 
> > *Enseignant de mathématiques en Lycée **et développeur Python amateur* 
> > *---* 
> > *French math teacher in a "Lycée" **and **Python **amateur developer* 
> > 
> > -- 
> > 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Pyzo] how to execute python magics from script

2016-10-07 Thread Dietrich Pescoller
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Pyzo] Very strange/possibly dangerous behaviour of %edit

2016-10-01 Thread Dietrich Pescoller
Understood, 
many thanks for the explanation.

Dietrich


Il giorno sabato 1 ottobre 2016 13:45:04 UTC+2, Almar Klein ha scritto:
>
> AFAIK the %edit command is supposed to run the contents of the file when 
> it is closed. In the way that it works with Pyzo, it seems to make IPython 
> think that the file is closed emmidiately, so it runs it at once.
>
>  
>
> Therefore, I’d suggest to not use this command, but use “open some_object“ 
> instead.
>
>  
>
> - Almar
>
>  
>
>  
>
>  
>
> *From: *Dietrich Pescoller 
> *Sent: *29 September 2016 11:34
> *To: *Pyzo 
> *Subject: *[Pyzo] Very strange/possibly dangerous behaviour of %edit
>
>  
>
> Hi,
>
> when I do 
> %edit of a module I have observed that it does not only open the file in 
> the editor but it also executes it.
>
> For instance if I have the following module:
> ==
> def myFun(): 
>
> print('I was called')
>
>  
>
> if __name__ == '__main__':
>
> myFun()
>
> ==
>
>
> and i call %edit i get:
>
>
> In [*5*]: %edit myFun
>
> Editing... done. Executing edited code...
>
> I was called
>
>  
>
>  
>
> So the module is not only opened but also executed!
> This should not be. 
>
>  
>
> Bye,
>
> 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.