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
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
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)
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
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
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
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
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
> > >
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():
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.
> > >
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:
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,
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
> >> >...
>
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):
>...
>
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 = ''
> >...
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
16 matches
Mail list logo