Re: How to make a variable's late binding crosses the module boundary?

2022-09-01 Thread Jach Feng
ery...@gmail.com 在 2022年9月2日 星期五凌晨12:41:46 [UTC+8] 的信中寫道: > On 8/31/22, Jach Feng wrote: > > > > I found that using "from test import *" in test2.py makes test2's relation > > to "test" almost like the function's relation to the module where it is > > defined. You can refer to all the variable

Re: How to make a variable's late binding crosses the module boundary?

2022-09-01 Thread Eryk Sun
On 8/31/22, Jach Feng wrote: > > I found that using "from test import *" in test2.py makes test2's relation > to "test" almost like the function's relation to the module where it is > defined. You can refer to all the variables of the module Note that in general, if __all__ doesn't exist to expli

Re: How to make a variable's late binding crosses the module boundary?

2022-09-01 Thread Jach Feng
Mark Bourne 在 2022年9月1日 星期四凌晨2:43:40 [UTC+8] 的信中寫道: > Jach Feng wrote: > > Mark Bourne 在 2022年8月29日 星期一下午6:40:59 [UTC+8] 的信中寫道: > >> Jach Feng wrote: > >>> Chris Angelico 在 2022年8月29日 星期一下午1:58:58 [UTC+8] 的信中寫道: > On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > > > > Richard Da

Re: How to make a variable's late binding crosses the module boundary?

2022-08-31 Thread Mark Bourne
Jach Feng wrote: Mark Bourne 在 2022年8月29日 星期一下午6:40:59 [UTC+8] 的信中寫道: Jach Feng wrote: Chris Angelico 在 2022年8月29日 星期一下午1:58:58 [UTC+8] 的信中寫道: On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: Richard Damon 在 2022年8月29日 星期一上午10:47:08 [UTC+8] 的信中寫道: On 8/27/22 7:42 AM, Mark Bourne wrote: Jach

Re: How to make a variable's late binding crosses the module boundary?

2022-08-31 Thread Antoon Pardon
Op 31/08/2022 om 09:53 schreef dn: On 31/08/2022 19.38, Antoon Pardon wrote: Op 30/08/2022 om 23:52 schreef dn: The conversation seems to be wandering some way from the OP. Whereas both of these answers are clever (and I assume work), the question becomes: why would you want to do this? (esp

Re: How to make a variable's late binding crosses the module boundary?

2022-08-31 Thread dn
On 31/08/2022 19.38, Antoon Pardon wrote: > > > Op 30/08/2022 om 23:52 schreef dn: >> The conversation seems to be wandering some way from the OP. Whereas >> both of these answers are clever (and I assume work), the question >> becomes: why would you want to do this? (especially as it looks ugly

Re: How to make a variable's late binding crosses the module boundary?

2022-08-31 Thread Antoon Pardon
Op 30/08/2022 om 23:52 schreef dn: The conversation seems to be wandering some way from the OP. Whereas both of these answers are clever (and I assume work), the question becomes: why would you want to do this? (especially as it looks ugly and 'smells' a bit convoluted). An example use-case fr

Re: How to make a variable's late binding crosses the module boundary?

2022-08-30 Thread dn
same > things we want to be global. > > Joseph S. > > Teledyne Confidential; Commercially Sensitive Business Data > > -Original Message- > From: Stefan Ram > Sent: Tuesday, August 30, 2022 1:09 AM > To: python-list@python.org > Subject: Re: How t

RE: How to make a variable's late binding crosses the module boundary?

2022-08-30 Thread Schachner, Joseph (US)
Ram Sent: Tuesday, August 30, 2022 1:09 AM To: python-list@python.org Subject: Re: How to make a variable's late binding crosses the module boundary? dn writes: >Build module.py as: >*** >CONSTANT = 1 >def func(): >pass >*** >then in the terminal: >*** >Python

Re: How to make a variable's late binding crosses the module boundary?

2022-08-29 Thread dn
On 30/08/2022 06.45, Peter J. Holzer wrote: > The module is imported but it isn't bound to any name in the current > (global) namespace (obviously there must be some variable bound to it, but > that's probably a local variable in the importer and it isn't called > `x`). Then the object bound to th

Re: How to make a variable's late binding crosses the module boundary?

2022-08-29 Thread Jach Feng
Mark Bourne 在 2022年8月29日 星期一下午6:40:59 [UTC+8] 的信中寫道: > Jach Feng wrote: > > Chris Angelico 在 2022年8月29日 星期一下午1:58:58 [UTC+8] 的信中寫道: > >> On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > >>> > >>> Richard Damon 在 2022年8月29日 星期一上午10:47:08 [UTC+8] 的信中寫道: > On 8/27/22 7:42 AM, Mark Bourne wr

Re: How to make a variable's late binding crosses the module boundary?

2022-08-29 Thread Peter J. Holzer
On 2022-08-29 11:40:33 +0100, Mark Bourne wrote: > Jach Feng wrote: > > Chris Angelico 在 2022年8月29日 星期一下午1:58:58 [UTC+8] 的信中寫道: > > > On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > > > > Sometimes I am wondering why "from x import y" hides x? > > > > hum...can't figure out the reason:-) > > > >

Re: How to make a variable's late binding crosses the module boundary?

2022-08-29 Thread Chris Angelico
On Tue, 30 Aug 2022 at 02:38, Jach Feng wrote: > > Chris Angelico 在 2022年8月29日 星期一下午1:58:58 [UTC+8] 的信中寫道: > > On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > > > > > > Richard Damon 在 2022年8月29日 星期一上午10:47:08 [UTC+8] 的信中寫道: > > > > On 8/27/22 7:42 AM, Mark Bourne wrote: > > > > > Jach Feng wrot

Re: How to make a variable's late binding crosses the module boundary?

2022-08-29 Thread Mark Bourne
Jach Feng wrote: Chris Angelico 在 2022年8月29日 星期一下午1:58:58 [UTC+8] 的信中寫道: On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: Richard Damon 在 2022年8月29日 星期一上午10:47:08 [UTC+8] 的信中寫道: On 8/27/22 7:42 AM, Mark Bourne wrote: Jach Feng wrote: I have two files: test.py and test2.py --test.py-- x = 2 d

Re: How to make a variable's late binding crosses the module boundary?

2022-08-29 Thread Jach Feng
Chris Angelico 在 2022年8月29日 星期一下午1:58:58 [UTC+8] 的信中寫道: > On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > > > > Richard Damon 在 2022年8月29日 星期一上午10:47:08 [UTC+8] 的信中寫道: > > > On 8/27/22 7:42 AM, Mark Bourne wrote: > > > > Jach Feng wrote: > > > >> I have two files: test.py and test2.py > > >

Re: How to make a variable's late binding crosses the module boundary?

2022-08-28 Thread Chris Angelico
On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > > Richard Damon 在 2022年8月29日 星期一上午10:47:08 [UTC+8] 的信中寫道: > > On 8/27/22 7:42 AM, Mark Bourne wrote: > > > Jach Feng wrote: > > >> I have two files: test.py and test2.py > > >> --test.py-- > > >> x = 2 > > >> def foo(): > > >> print(x) > > >> f

Re: How to make a variable's late binding crosses the module boundary?

2022-08-28 Thread Jach Feng
Richard Damon 在 2022年8月29日 星期一上午10:47:08 [UTC+8] 的信中寫道: > On 8/27/22 7:42 AM, Mark Bourne wrote: > > Jach Feng wrote: > >> I have two files: test.py and test2.py > >> --test.py-- > >> x = 2 > >> def foo(): > >> print(x) > >> foo() > >> > >> x = 3 > >> foo() > >> > >> --test2.py--

Re: How to make a variable's late binding crosses the module boundary?

2022-08-28 Thread Richard Damon
On 8/27/22 7:42 AM, Mark Bourne wrote: Jach Feng wrote: I have two files: test.py and test2.py --test.py-- x = 2 def foo(): print(x) foo() x = 3 foo() --test2.py-- from test import * x = 4 foo() - Run test.py under Winows8.1, I get the expected result: e:\MyDocument>py test.py 2 3 B

Re: How to make a variable's late binding crosses the module boundary?

2022-08-28 Thread Jach Feng
Mark Bourne 在 2022年8月27日 星期六晚上7:42:37 [UTC+8] 的信中寫道: > import test > test.x = 4 > test.foo() > > -- > Mark. Yes, you are right. But because of I am using "from test import *" which makes the name "test" disappear in the test2 scope, so this is not work. I solved this problem by moving "x" to

Re: How to make a variable's late binding crosses the module boundary?

2022-08-28 Thread Mark Bourne
Jach Feng wrote: I have two files: test.py and test2.py --test.py-- x = 2 def foo(): print(x) foo() x = 3 foo() --test2.py-- from test import * x = 4 foo() - Run test.py under Winows8.1, I get the expected result: e:\MyDocument>py test.py 2 3 But when run test2.py, the result is not