Re: What's the difference between running a script under command box and interpreter?

2019-11-04 Thread jfong
Grant Edwards於 2019年11月5日星期二 UTC+8上午12時41分24秒寫道: > On 2019-11-04, Dennis Lee Bieber wrote: > > Using > > > >from module import * > > > > is often the worst thing one can do. > > I agree 100%. > > Unfortunately, most of the official standard library documentation is > written assuming you do

Re: What's the difference between running a script under command box and interpreter?

2019-11-04 Thread MRAB
On 2019-11-04 21:05, Peter J. Holzer wrote: On 2019-11-03 16:34:39 -0800, jf...@ms4.hinet.net wrote: I innocently thought that when import module through "from test import *", I am working on test's globals under REPL. I didn't noticed the REPL has its own globals. Well, you imported every

Re: What's the difference between running a script under command box and interpreter?

2019-11-04 Thread Peter J. Holzer
On 2019-11-03 16:34:39 -0800, jf...@ms4.hinet.net wrote: > I innocently thought that when import module through "from test import > *", I am working on test's globals under REPL. I didn't noticed the > REPL has its own globals. Well, you imported every global from test. So you are (kind of)

Re: What's the difference between running a script under command box and interpreter?

2019-11-04 Thread Grant Edwards
On 2019-11-04, Dennis Lee Bieber wrote: > Using > >from module import * > > is often the worst thing one can do. I agree 100%. Unfortunately, most of the official standard library documentation is written assuming you do _exactly_that_. Though it makes the documetnation more succinct, I

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread Chris Angelico
On Mon, Nov 4, 2019 at 3:16 PM wrote: > > Chris Angelico於 2019年11月4日星期一 UTC+8上午10時19分50秒寫道: > > On Mon, Nov 4, 2019 at 1:01 PM wrote: > > > > > > Chris Angelico於 2019年11月4日星期一 UTC+8上午8時43分07秒寫道: > > > > Ah, that's a fair point. If you specifically WANT that behaviour, what > > > > you can do is

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread jfong
Chris Angelico於 2019年11月4日星期一 UTC+8上午10時19分50秒寫道: > On Mon, Nov 4, 2019 at 1:01 PM wrote: > > > > Chris Angelico於 2019年11月4日星期一 UTC+8上午8時43分07秒寫道: > > > Ah, that's a fair point. If you specifically WANT that behaviour, what > > > you can do is invoke the script interactively: > > > > > > python3

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread Chris Angelico
On Mon, Nov 4, 2019 at 1:01 PM wrote: > > Chris Angelico於 2019年11月4日星期一 UTC+8上午8時43分07秒寫道: > > Ah, that's a fair point. If you specifically WANT that behaviour, what > > you can do is invoke the script interactively: > > > > python3 -i test.py > > > > That'll run the script as normal, and then

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread jfong
Chris Angelico於 2019年11月4日星期一 UTC+8上午8時43分07秒寫道: > On Mon, Nov 4, 2019 at 11:36 AM wrote: > > > > Peter J. Holzer於 2019年11月4日星期一 UTC+8上午3時59分36秒寫道: > > > On 2019-11-01 04:24:38 -0700, jf...@ms4.hinet.net wrote: > > > > > The globals are your current module's namespace, and functions defines > > >

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread Cameron Simpson
On 03Nov2019 16:34, Jach Fong wrote: Peter J. Holzer於 2019年11月4日星期一 UTC+8上午3時59分36秒寫道: It's not really "the interpreter" (I think you mean the REPL) which has it's own globals. Every module/file has its own globals. The same thing happens non-interactively: % cat test.py def main():

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread Chris Angelico
On Mon, Nov 4, 2019 at 11:36 AM wrote: > > Peter J. Holzer於 2019年11月4日星期一 UTC+8上午3時59分36秒寫道: > > On 2019-11-01 04:24:38 -0700, jf...@ms4.hinet.net wrote: > > > > The globals are your current module's namespace, and functions defines > > > > in a module are bound to that module's namespace. > > >

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread jfong
Peter J. Holzer於 2019年11月4日星期一 UTC+8上午3時59分36秒寫道: > On 2019-11-01 04:24:38 -0700, jf...@ms4.hinet.net wrote: > > > The globals are your current module's namespace, and functions defines > > > in a module are bound to that module's namespace. > > > > > > Strip your test.py back. A lot. Try this:

Re: What's the difference between running a script under command box and interpreter?

2019-11-03 Thread Peter J. Holzer
On 2019-11-01 04:24:38 -0700, jf...@ms4.hinet.net wrote: > > The globals are your current module's namespace, and functions defines > > in a module are bound to that module's namespace. > > > > Strip your test.py back. A lot. Try this: > > > > def main(): > > print(rule) > > > > Now,

Re: What's the difference between running a script under command box and interpreter?

2019-11-01 Thread jfong
Cameron Simpson於 2019年11月1日星期五 UTC+8下午5時28分42秒寫道: > On 31Oct2019 22:03, Jach Fong wrote: > >Cameron Simpson於 2019年11月1日星期五 UTC+8下午12時13分45秒寫道: > >> On 31Oct2019 20:44, Jach Fong wrote: > >> >The script test.py is something like this: > >> >---test.py > >> >from pyeds import fsm > >> >... >

Re: What's the difference between running a script under command box and interpreter?

2019-11-01 Thread Cameron Simpson
On 31Oct2019 22:03, Jach Fong wrote: Cameron Simpson於 2019年11月1日星期五 UTC+8下午12時13分45秒寫道: On 31Oct2019 20:44, Jach Fong wrote: >The script test.py is something like this: >---test.py >from pyeds import fsm >... >class Rule_Parse: >def __init__(self): >... >

Re: What's the difference between running a script under command box and interpreter?

2019-10-31 Thread jfong
Cameron Simpson於 2019年11月1日星期五 UTC+8下午12時13分45秒寫道: > On 31Oct2019 20:44, Jach Fong wrote: > >The script test.py is something like this: > >---test.py > >from pyeds import fsm > >... > >... > >class Rule_Parse: > >def __init__(self): > >... > >self.current_char = '' > >...

Re: What's the difference between running a script under command box and interpreter?

2019-10-31 Thread Cameron Simpson
On 31Oct2019 20:44, Jach Fong wrote: The script test.py is something like this: ---test.py from pyeds import fsm ... ... class Rule_Parse: def __init__(self): ... self.current_char = '' ... ... def main(input_str): for c in input_str: ... rule.current_char