Re: Question about "Import leoGlobals, but do NOT set g."

2020-01-07 Thread Edward K. Ream
On Fri, Jan 3, 2020 at 4:42 PM Brian Theado  wrote:

>>> I thought the 'g' and 'leoGlobals' identifiers are local to the
runLeo.py file. I don't see how having the name be 'leoGlobals' instead of
'g' for two lines of code could affect anything.

>> If you really want to know why the code is as it is, create a new branch
and change the code ;-)

> Excellent advice.  I just now tried it though and nothing broke. I was
able to run the gui just fine and I was also able run all the unit tests
fine. I made the changes to both runLeo and leoBridge.

Thanks.  I have just created #1472
 for this.  I'll get
to it soon.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAMF8tS0XD32jQ%2BZv6vaiuLH3r7xzoM0rV-MHK6mUhnYhLuZJxA%40mail.gmail.com.


Re: Question about "Import leoGlobals, but do NOT set g."

2020-01-03 Thread Brian Theado
On Fri, Jan 3, 2020 at 7:21 AM Edward K. Ream  wrote:

> On Thu, Jan 2, 2020 at 12:11 PM Brian Theado 
> wrote:
>
> For runLeo.py, the code looks like this:
>>
>> # Import leoGlobals, but do NOT set g.
>> import leo.core.leoGlobals as leoGlobals
>> # Create g.app.
>> import leo.core.leoApp as leoApp
>> leoGlobals.app = leoApp.LeoApp()
>> # **Now** we can set g.
>> g = leoGlobals
>> assert(g.app)
>>
>>
>> I thought the 'g' and 'leoGlobals' identifiers are local to the runLeo.py
>> file. I don't see how having the name be 'leoGlobals' instead of 'g' for
>> two lines of code could affect anything.
>>
>
> I don't remember the details, but I suspect that they concern the binding
> of g while leoGlobals.py itself is being imported.
>

I was thinking along these lines, but if that is the case, then I have a
big gap in my understanding of how python identifiers and binding works and
I want to close the gap.


> If you really want to know why the code is as it is, create a new branch
> and change the code ;-)
>

Excellent advice.  I just now tried it though and nothing broke. I was able
to run the gui just fine and I was also able run all the unit tests fine. I
made the changes to both runLeo and leoBridge.

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAO5X8Cy%2BNQM9wVTtezR-MWLtbjHDoS%3DUnYPpqvnwTNTn%2BmNTMA%40mail.gmail.com.


Re: Question about "Import leoGlobals, but do NOT set g."

2020-01-03 Thread Edward K. Ream
On Thu, Jan 2, 2020 at 12:11 PM Brian Theado  wrote:

For runLeo.py, the code looks like this:
>
> # Import leoGlobals, but do NOT set g.
> import leo.core.leoGlobals as leoGlobals
> # Create g.app.
> import leo.core.leoApp as leoApp
> leoGlobals.app = leoApp.LeoApp()
> # **Now** we can set g.
> g = leoGlobals
> assert(g.app)
>
>
> I thought the 'g' and 'leoGlobals' identifiers are local to the runLeo.py
> file. I don't see how having the name be 'leoGlobals' instead of 'g' for
> two lines of code could affect anything.
>

The code in question occurs very early in Leo's startup code.

I don't remember the details, but I suspect that they concern the binding
of g while leoGlobals.py itself is being imported.

If you really want to know why the code is as it is, create a new branch
and change the code ;-)

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAMF8tS1-AwiesOKVF8s840GCh1w4F6qmu56n03ytSL8psUR9_A%40mail.gmail.com.


Question about "Import leoGlobals, but do NOT set g."

2020-01-02 Thread Brian Theado
Both of these places in Leo's code:
https://github.com/leo-editor/leo-editor/blob/devel/leo/core/runLeo.py#L24
https://github.com/leo-editor/leo-editor/blob/devel/leo/core/leoBridge.py#L108

has the comment "Import leoGlobals, but do NOT set g."

For runLeo.py, the code looks like this:

# Import leoGlobals, but do NOT set g.
import leo.core.leoGlobals as leoGlobals
# Create g.app.
import leo.core.leoApp as leoApp
leoGlobals.app = leoApp.LeoApp()
# **Now** we can set g.
g = leoGlobals
assert(g.app)


I thought the 'g' and 'leoGlobals' identifiers are local to the runLeo.py
file. I don't see how having the name be 'leoGlobals' instead of 'g' for
two lines of code could affect anything. IOW, how is the above code any
different from:

import leo.core.leoGlobals as g
# Create g.app.
import leo.core.leoApp as leoApp
g.app = leoApp.LeoApp()
assert(g.app)


Is there something about python identifiers I'm missing?

Brian

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAO5X8CysF4msw%3DgsiNv3pT_N2ZiKr7G%2BB9vYVtO1i1PLsUz5pQ%40mail.gmail.com.