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

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

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

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:

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?

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

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

2022-08-30 Thread dn
On 31/08/2022 05.26, Schachner, Joseph (US) wrote: > The way we do this, is in main.py, call a "globalizer" function in each other > file: > > # call globalizers to get shortcuts as global variables > funcs.globalizer(interface, variable_dict) > util.globalizer(interface,

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

2022-08-30 Thread Schachner, Joseph (US)
The way we do this, is in main.py, call a "globalizer" function in each other file: # call globalizers to get shortcuts as global variables funcs.globalizer(interface, variable_dict) util.globalizer(interface, variable_dict) sd.globalizer(interface, variable_dict)

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

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

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

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

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-29 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) > > >>

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

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"

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