Re: Extract lines from file, add to new files

2024-01-11 Thread Thomas Passin via Python-list

On 1/11/2024 1:27 PM, MRAB via Python-list wrote:

On 2024-01-11 18:08, Rich Shepard via Python-list wrote:

It's been several years since I've needed to write a python script so I'm
asking for advice to get me started with a brief script to separate names
and email addresses in one file into two separate files: 
salutation.txt and

emails.txt.

An example of the input file:

Calvin
cal...@example.com

Hobbs
ho...@some.com

Nancy
na...@herown.com

Sluggo
slu...@another.com

Having extracted salutations and addresses I'll write a bash script using
sed and mailx to associate a message file with each name and email 
address.


I'm unsure where to start given my lack of recent experience.


 From the look of it:

1. If the line is empty, ignore it.

2. If the line contains "@", it's an email address.

3. Otherwise, it's a name.


You could think about a single Python script that looks through your 
input file and constructs all the message files without ever writing 
separate salutation and address files at all.  Then you wouldn't need to 
write the sed and mailx scripts.  It shouldn't be much harder than 
peeling out the names and addresses into separate files.


If you haven't written any Python for some years, the preferred way to 
read and write files is using a "with" statement, like this:


with open('email_file.txt', encoding = 'utf-8') as f:
lines = f.readlines()
for line in lines:
if not line.strip():  # Skip blank lines
continue
# Do something with this line

You don't need to close the file because when the "with" block ends the 
file will be closed for you.


If the encoding is not utf-8 and you know what it will be, use that 
encoding instead.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Discuss: what should path expressions contain?

2024-01-10 Thread Thomas Passin
I just did some testing on Windows, and with an @file node Leo acts as if 
the os.path functions expanduser() and expandvars() are applied, as well as 
the  abspath() that would be expected (and probably realpath() but I didn't 
check that).  This means that you can set an environmental variable, say 
VAR, and use it in the path expression as $VAR.  I didn't find any 
variables that seem to have been added by Leo.

I didn't find where in LeoPyRef.leo this all happens.

On Wednesday, January 10, 2024 at 9:53:06 AM UTC-5 jkn wrote:

> On Wednesday, January 10, 2024 at 1:00:58 PM UTC tbp1...@gmail.com wrote:
>
> Edward made some changes during this thread, IIRC.
>
>
> Yes ... I was trying to track the end results of this.
>
> The description of {{sep}} etc. used to be on the leoeditor.com 
> documentation,
> but no longer seems to be there.
> A short 'migration guide' paragraph would be useful, it was not clear to me
> that my nodes with this style of directives need to be changed.
>  
>
> On Wednesday, January 10, 2024 at 5:21:22 AM UTC-5 Edward K. Ream wrote:
>
> On Tue, Jan 9, 2024 at 1:14 PM jkn  wrote:
>
> did the work that got done here ever get documented? 
>
>
> Luke, use the find command!
>
> Searching LeoDocs.leo for "path expression" yields these items from the 
> 6.1 release notes:
>
> - #1338 : 
> g.getUrlFromNode must not expand path expressions.
> - #1341 : Expansion 
> of path expressions should be strictly limited.
>
> My only memory of these issues is that path expressions *must not* 
> execute arbitrary code!
>
> It looks like the fixes happened before Leo started using PRs, so it's 
> much harder to pinpoint the actual changes.
>
> 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/55ed6e19-b92d-4cfb-ac1b-d67988129f6fn%40googlegroups.com.


Re: Discuss: what should path expressions contain?

2024-01-10 Thread Thomas Passin
Edward made some changes during this thread, IIRC.

On Wednesday, January 10, 2024 at 5:21:22 AM UTC-5 Edward K. Ream wrote:

> On Tue, Jan 9, 2024 at 1:14 PM jkn  wrote:
>
>> did the work that got done here ever get documented? 
>>
>
> Luke, use the find command!
>
> Searching LeoDocs.leo for "path expression" yields these items from the 
> 6.1 release notes:
>
> - #1338 : 
> g.getUrlFromNode must not expand path expressions.
> - #1341 : Expansion 
> of path expressions should be strictly limited.
>
> My only memory of these issues is that path expressions *must not* 
> execute arbitrary code!
>
> It looks like the fixes happened before Leo started using PRs, so it's 
> much harder to pinpoint the actual changes.
>
> 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/41eab2db-58d4-4e61-990c-03d02509498dn%40googlegroups.com.


Re: ENB: About leoTokens.py

2024-01-06 Thread Thomas Passin

On Saturday, January 6, 2024 at 7:31:52 AM UTC-5 Edward K. Ream wrote:

I could not have refactored the code without Leo.


It would be interesting to read more about this. Other IDEs claim to 
support refactoring.  How did Leo make it possible in a way that others 
would not have?

-- 
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/a3ecaf79-1567-4bec-a323-9c85abe76eb9n%40googlegroups.com.


Re: Using my routines as functions AND methods

2024-01-04 Thread Thomas Passin via Python-list

On 1/3/2024 8:00 PM, Alan Gauld via Python-list wrote:

On 03/01/2024 22:47, Guenther Sohler via Python-list wrote:

Hi,

In my cpython i have written quite some functions to modify "objects".
and their python syntax is e.g.\

translate(obj, vec). e.g whereas obj is ALWAYS first argument.



However, I also want to use these functions as class methods without having
to
write the function , twice. When using the SAME function as a methos, the
args tuple must insert/contain "self" in the first location, so i have
written a function to do that:


I'm probably missing something obvious here but can't you
just assign your function to a class member?

def myFunction(obj, ...): ...

class MyClass:
 myMethod = myFunction


Then you can call it as

myObject = MyClass()
myObject.myMethod()

A naive example seems to work but I haven't tried anything
complex so there is probably a catch. But sometimes the simple
things just work?


That works if you assign the function to a class instance, but not if 
you assign it to a class.


def f1(x):
print(x)
f1('The plain function')

class Class1:
pass

class Class2:
pass

c1 = Class1()
c1.newfunc = f1
c1.newfunc('f1 assigned to instance') # Works as intended

Class2.newfunc = f1
c2 = Class2()
c2.newfunc('f1 assigned to class')  # Complains about extra argument


--
https://mail.python.org/mailman/listinfo/python-list


Re: Using my routines as functions AND methods

2024-01-03 Thread Thomas Passin via Python-list

On 1/3/2024 11:17 PM, Thomas Passin wrote:

On 1/3/2024 8:00 PM, Alan Gauld via Python-list wrote:

On 03/01/2024 22:47, Guenther Sohler via Python-list wrote:

Hi,

In my cpython i have written quite some functions to modify "objects".
and their python syntax is e.g.\

translate(obj, vec). e.g whereas obj is ALWAYS first argument.


However, I also want to use these functions as class methods without 
having

to
write the function , twice. When using the SAME function as a methos, 
the

args tuple must insert/contain "self" in the first location, so i have
written a function to do that:


I'm probably missing something obvious here but can't you
just assign your function to a class member?

def myFunction(obj, ...): ...

class MyClass:
 myMethod = myFunction


Then you can call it as

myObject = MyClass()
myObject.myMethod()

A naive example seems to work but I haven't tried anything
complex so there is probably a catch. But sometimes the simple
things just work?


That works if you assign the function to a class instance, but not if 
you assign it to a class.


def f1(x):
     print(x)
f1('The plain function')

class Class1:
     pass

class Class2:
     pass

c1 = Class1()
c1.newfunc = f1
c1.newfunc('f1 assigned to instance') # Works as intended

Class2.newfunc = f1
c2 = Class2()
c2.newfunc('f1 assigned to class')  # Complains about extra argument


If your requirements are not very tricky, you can write a 
convert-to-method function yourself:


def f1(x):
print(x)
f1('The plain function')

class Class2:
pass

def convert_method(f):
"""Assign existing method without a "self" arg
   as a class's method.
"""
def fnew(instance, *args):
f(*args)
return fnew

Class2.newfunc = convert_method(f1)
c2 = Class2()
c2.newfunc('f1 assigned as method of Class2') # Prints the arg

This example does not make f1 aware of the self argument, but you asked 
to convert an existing function, and that function would not be aware of 
the self parameter. It's much like a decorator function, but is not here 
being used as a decorator. If you meant something else, please think out 
what you want and explain that.


--
https://mail.python.org/mailman/listinfo/python-list


Re: LeoJS - How To Write To File System And Run External Programs

2024-01-03 Thread Thomas Passin
Yay!

On Wednesday, January 3, 2024 at 7:12:26 PM UTC-5 Félix wrote:

> I'm going to take a coding break by doing a tutorial exactly about that!
>
> On Wednesday, January 3, 2024 at 4:56:12 PM UTC-5 tbp1...@gmail.com wrote:
>
>> Now That leoJS is getting into pretty good shape - and Felix must need a 
>> month's vacation! - I am thinking about plugins and scripts that can do 
>> things that are easy to do from within Leo. Specifically, scripts that can 
>> read and write files from the file system, and files that do the equivalent 
>> of subprocess.run() or subprocess.Popen().  In addition (or maybe it's in 
>> the same group), scripts that launch a web browser on a specified file.
>>
>> Is there somewhere we can read up on these things, that is, how a leoJS 
>> script can do them in javascript/typescript?
>>
>

-- 
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/074f8a79-01d6-4bf0-94e6-6a8ebab90d43n%40googlegroups.com.


Re: Issue #3710: EKR's last lecture

2024-01-03 Thread Thomas Passin
That Pluto really whets my appetite!

On Wednesday, January 3, 2024 at 5:41:24 PM UTC-5 off...@riseup.net wrote:

> Also I recently discovered Julia's Pluto[1][1a] and I really like their 
> focused notebook environment saved in plain text instead of Jupyter's 
> cumbersome and human unfriendly JSON. A breath of fresh air, following the 
> steps in human/diff friendly formats for interactive notebooks of Pharo's 
> Grafoscopio, Elixir's LiveBook or Clojure's Clerk.
>
> I don't know about Nim's scientific ecosystem (Julia seems better in that 
> regard). But one of the advantage of novice's mind is that we can start 
> without the heaviness and even ignore the one related with popularity of 
> fashion (like the one in Rust these days).
>
> [1] https://cinemaphile.com/watch?v=Rg3r3gG4nQo
> [1a] https://plutojl.org/
>
> Cheers,
>
> Offray
> On 30/12/23 9:39, Thomas Passin wrote:
>
> Looks like Nim can use a good range of scientific computing libraries, and 
> there are some GUI libraries.  So at this point the two compiled languages 
> that would be if serious interest to me would be Nim and Julia.
>
> On Saturday, December 30, 2023 at 2:26:06 AM UTC-5 Edward K. Ream wrote:
>
>> On Sat, Dec 30, 2023 at 12:15 AM Edward K. Ream  wrote
>>
>> So yes, I would use nim if I could.
>>>
>>> I've just glanced at nim code.  "I" instead of "if"??
>>>
>>
>> Never mind. nim's intro page clearly shows python-like keywords. 
>>
>> I thought I was reading nim code at https://rosettacode.org/wiki, but I 
>> must have been reading something else :-)
>>
>> 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+...@googlegroups.com.
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/leo-editor/643c36d7-6002-4a21-9b04-6537e4bf8692n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/leo-editor/643c36d7-6002-4a21-9b04-6537e4bf8692n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
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/713b216e--4e2e-b4da-92c59f559b5dn%40googlegroups.com.


LeoJS - How To Write To File System And Run External Programs

2024-01-03 Thread Thomas Passin
Now That leoJS is getting into pretty good shape - and Felix must need a 
month's vacation! - I am thinking about plugins and scripts that can do 
things that are easy to do from within Leo. Specifically, scripts that can 
read and write files from the file system, and files that do the equivalent 
of subprocess.run() or subprocess.Popen().  In addition (or maybe it's in 
the same group), scripts that launch a web browser on a specified file.

Is there somewhere we can read up on these things, that is, how a leoJS 
script can do them in javascript/typescript?

-- 
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/2fc44e6f-873c-4466-bed9-2c4e12f8d737n%40googlegroups.com.


Re: LeoJS - How To Print javascript Output?

2024-01-02 Thread Thomas Passin
Ha! Should have tried that right off!.  Thanks.

On Tuesday, January 2, 2024 at 8:16:51 PM UTC-5 Félix wrote:

> Hi Thomas! :)
>
> I gather that by an 'Output window' you mean the LeoJS Log Window? (The 
> equivalent of Leo's Log Window)
> [image: log_pane.png]
>
> Using *console.log (*which is indeed the equivalent of python's *print 
> *function, 
> which prints in the terminal instead of Leo's Log Window), will itself 
> indeed print in the developer's-tools-terminal. (not recommended)
>
> What I recommend in contrast, is the *g.es  *function (and 
> other 'g' methods like es_print, etc.) which does print in the Log Window. 
>
> See (and study) this example script that gives a few pointers on how to do 
> various useful stuff :
>
> @language javascript
> const vscode = g.app.vscode;
> g.es("hahahaha");
> // 'await' for doCommandByName required only if other code in script is 
> 'awaited'.
> await c.doCommandByName('insert-headline-time');
>
> const userInput = await vscode.window.showInputBox({
> placeHolder: 'Enter something', // Placeholder text in the input box
> prompt: 'Please enter some text:', // Prompt message above the input 
> box
> });
> if (userInput === undefined) {
> g.es('User canceled the input.');
> } else {
> g.es('User input:', userInput);
> }
> try {
> const apiUrl = 'https://jsonplaceholder.typicode.com/users';
> const response = await fetch(apiUrl);
> g.es("about to call");
> if (!response.ok) {
> throw new Error('Network response was not ok');
> }
> const data = await response.json();
> g.es("got it!!", JSON.stringify(data));
> } catch (error) {
> g.es("oh no!");
> console.error('Fetch error:', error);
> }
>
>
> It will insert the current time on the selected node, then pop an input 
> box and print it back out in the log window, along with the result of an 
> HTTP fetch call to some test API. Here is a screenshot of the result of 
> running this script online in vscode on the web :
> [image: screen_script_web.png]
>
> Hope this helps! 
>
> Félix
>
> On Tuesday, January 2, 2024 at 12:43:46 PM UTC-5 tbp1...@gmail.com wrote:
>
>> This script apparently runs without error but nothing shows in the Output 
>> window:
>>
>> @language javascript
>> console.log('this is another test');
>>
>> Using print() doesn't work, of course, because there isn't a print() 
>> function.  How can we get a visible output?
>>
>

-- 
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/aad78de7-378b-45eb-9e88-4422c436ebban%40googlegroups.com.


Re: ✨LeoJS beta 0.2.8 Released!

2024-01-02 Thread Thomas Passin
On Tuesday, January 2, 2024 at 10:36:44 AM UTC-5 jkn wrote:

(I have also probably been getting confused between LeoInteg and LeoJS: the 
page Felix links to has 'how to install LeoInteg' at the top...)

I have two issues on first attempts to use LeoJS, or at least to use it in 
the same environment as I run 'Leo Classic' in:

1) This is probably OS/distribution specific. I am running VSCodium under 
Kubuntu Linux. When I try to open a file, the open dialog appear *in the 
panel/toolbar*, ie. not as a sized window. I have to explicitly open the 
dialog by clicking in the toolbar. as I say, I think this is an artefact of 
my distribution, but if anyone knows how to fix it I'd be grateful


I just installed it on XUbuntu and didn't see this issue. 

-- 
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/d059e6ac-36d0-4e3f-8914-0f3a29f58041n%40googlegroups.com.


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-02 Thread Thomas Passin via Python-list

On 1/2/2024 11:56 AM, Mats Wichmann via Python-list wrote:

On 1/1/24 12:53, Thomas Passin via Python-list wrote:

On Windows 10, a shebang line gets ignored in favor of Python 3.9.9 
(if invoked by the script name alone) or Python 3.12.1 (if invoked by 
the "py" launcher).


fwiw, you can also create an ini file to define to the launcher py which 
version should be the default, if no version is specified.


You might learn about this if you happen to read and remember the right 
part of the Python docs.  Otherwise you have no idea what py.exe is up 
to nor how it does it.  I would say that most people don't know there's 
an ini file, let alone what it can do.  Of course this situation isn't 
unique to py.exe!


--
https://mail.python.org/mailman/listinfo/python-list


LeoJS - How To Print javascript Output?

2024-01-02 Thread Thomas Passin
This script apparently runs without error but nothing shows in the Output 
window:

@language javascript
console.log('this is another test');

Using print() doesn't work, of course, because there isn't a print() 
function.  How can we get a visible output?

-- 
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/26bae114-6eff-4dc6-babe-7517a82bc4fcn%40googlegroups.com.


Re: ✨LeoJS beta 0.2.8 Released!

2024-01-02 Thread Thomas Passin
I just installed VSCodium and leoJS on Linux Mint in a Virtual Machine.  I 
followed the instructions here 
 to 
install VSCodium. It all worked like a charm and I opened the Workbook 
without noticing anything unusual so far.

On Tuesday, January 2, 2024 at 11:07:46 AM UTC-5 jkn wrote:

> update:
>
> 1) I have got past my 'files open in another instance of Leo' problem. I 
> did remember that the cache is in ~/.leo/db etc, although I ended up not 
> doing it this way
> 2) I also seem to have sorted out my dialog opening issue - it does indeed 
> seem to be a VSCodium/Kubuntu problem. I have added a workaround rule to 
> the Window configuration.
>
> In the course of all of this I have updated 'Leo classic' and seem to have 
> hit a different issue ... I will raise as a separate thread.
>
> Sorry for the noise, J^n
>
>
> On Tuesday, January 2, 2024 at 3:36:44 PM UTC jkn wrote:
>
>> (I have also probably been getting confused between LeoInteg and LeoJS: 
>> the page Felix links to has 'how to install LeoInteg' at the top...)
>>
>> I have two issues on first attempts to use LeoJS, or at least to use it 
>> in the same environment as I run 'Leo Classic' in:
>>
>> 1) This is probably OS/distribution specific. I am running VSCodium under 
>> Kubuntu Linux. When I try to open a file, the open dialog appear *in the 
>> panel/toolbar*, ie. not as a sized window. I have to explicitly open the 
>> dialog by clicking in the toolbar. as I say, I think this is an artefact of 
>> my distribution, but if anyone knows how to fix it I'd be grateful
>>
>> 2) I am getting severe problems, having exited Codium and trying to start 
>> 'Leo Classic', with 'File already opened in another copy of Leo' errors. It 
>> took me a while to find the button to close a file in LeoJS; but even after 
>> going through the list of files and doing this one by one I am still 
>> getting this on multiple files. I recall there used to be some sort of 
>> cache file you could delete in these circumstances, but I can recall the 
>> details. anyone, please?
>>
>> Thanks, J^n
>>
>> On Tuesday, January 2, 2024 at 2:36:02 PM UTC tbp1...@gmail.com wrote:
>>
>>> That would probably be hard for a developer to keep up with, I would 
>>> think.  I remember the first time I went to install leoJS I got a similar 
>>> message, but VSC/odium upgraded in a flash so that I hardly knew what had 
>>> happened.  So it was a non-issue for me.
>>>
>>> On Tuesday, January 2, 2024 at 9:24:18 AM UTC-5 jkn wrote:
>>>
 A small point - it would be nice if the release notes mentioned what 
 version of VSCode/VSCodium
 was needed. I got a message that my version was too old.
 (I am running 1.77.1 of VSCodium, will upgrade shortly)

 Thanks, jon N

 On Tuesday, January 2, 2024 at 9:43:20 AM UTC jkn wrote:

> I like the graphic Felix, well done! ;-)
>
> Jon N
>
> On Tuesday, January 2, 2024 at 3:38:21 AM UTC Félix wrote:
>
>> 📣Introducing LeoJS Beta 0.2.8
>> LeoJS Beta 0.2.8 is here, bringing a substantial update filled with 
>> enhancements and critical fixes.
>> [image: _56d93bdf-e7f0-4625-85a2-cbf3cfc87fee.jpg]
>>
>> 🔍What's New in 0.2.8:
>>
>>- *Help Commands*: 'helpCommands.py' was converted to typescript, 
>>enabling help commands.
>>- *UNL Support*: Works in log pane, body panes, and all editor 
>>windows.
>>- *Goto-Script Fix*: Now works seamlessly with @button items.
>>- *Markdown*: The @auto markdown importer and writer now ensures 
>>flawless read-write integrity.
>>- *Undo/Redo for UAs*: Enhanced command support for 'Clear UAs' 
>>and 'Set UA'.
>>- *Clone Related Commands*: Fixes to 'show clone ancestors' and 
>>'show clone parents' commands.
>>- *Workspace-Specific Sessions*: Session management is now more 
>>personalized with workspace-specific settings.
>>- *Stable Node Selection*: LeoJS maintains focus on the selected 
>>node when refreshing external files.
>>- *gnx-kind Setting*: Choose between uuid, ksuid, or traditional 
>>GNX.
>>
>> 🚀 Continuous Improvements Since Launch:
>>
>>- Refined tooltips, language coloring support, and bug fixes in 
>>various importers.
>>- Enhanced keyboard navigation and pattern support for web 
>>browsers.
>>- Streamlined mobile experience, including 'ConfirmBeforeClose' 
>>improvements.
>>- Resolved issues with goto-next-clone and goto-next-marked 
>>refresh cycles, session management, and body pane labeling.
>>- Introduced user-friendly 'Recent Files' icons and buttons.
>>
>> If you can help to test it and note the bugs you find on the issues 
>> page , that'd be great! Join 
>> me and the comm

Re: ✨LeoJS beta 0.2.8 Released!

2024-01-02 Thread Thomas Passin
That would probably be hard for a developer to keep up with, I would 
think.  I remember the first time I went to install leoJS I got a similar 
message, but VSC/odium upgraded in a flash so that I hardly knew what had 
happened.  So it was a non-issue for me.

On Tuesday, January 2, 2024 at 9:24:18 AM UTC-5 jkn wrote:

> A small point - it would be nice if the release notes mentioned what 
> version of VSCode/VSCodium
> was needed. I got a message that my version was too old.
> (I am running 1.77.1 of VSCodium, will upgrade shortly)
>
> Thanks, jon N
>
> On Tuesday, January 2, 2024 at 9:43:20 AM UTC jkn wrote:
>
>> I like the graphic Felix, well done! ;-)
>>
>> Jon N
>>
>> On Tuesday, January 2, 2024 at 3:38:21 AM UTC Félix wrote:
>>
>>> 📣Introducing LeoJS Beta 0.2.8
>>> LeoJS Beta 0.2.8 is here, bringing a substantial update filled with 
>>> enhancements and critical fixes.
>>> [image: _56d93bdf-e7f0-4625-85a2-cbf3cfc87fee.jpg]
>>>
>>> 🔍What's New in 0.2.8:
>>>
>>>- *Help Commands*: 'helpCommands.py' was converted to typescript, 
>>>enabling help commands.
>>>- *UNL Support*: Works in log pane, body panes, and all editor 
>>>windows.
>>>- *Goto-Script Fix*: Now works seamlessly with @button items.
>>>- *Markdown*: The @auto markdown importer and writer now ensures 
>>>flawless read-write integrity.
>>>- *Undo/Redo for UAs*: Enhanced command support for 'Clear UAs' and 
>>>'Set UA'.
>>>- *Clone Related Commands*: Fixes to 'show clone ancestors' and 
>>>'show clone parents' commands.
>>>- *Workspace-Specific Sessions*: Session management is now more 
>>>personalized with workspace-specific settings.
>>>- *Stable Node Selection*: LeoJS maintains focus on the selected 
>>>node when refreshing external files.
>>>- *gnx-kind Setting*: Choose between uuid, ksuid, or traditional GNX.
>>>
>>> 🚀 Continuous Improvements Since Launch:
>>>
>>>- Refined tooltips, language coloring support, and bug fixes in 
>>>various importers.
>>>- Enhanced keyboard navigation and pattern support for web browsers.
>>>- Streamlined mobile experience, including 'ConfirmBeforeClose' 
>>>improvements.
>>>- Resolved issues with goto-next-clone and goto-next-marked refresh 
>>>cycles, session management, and body pane labeling.
>>>- Introduced user-friendly 'Recent Files' icons and buttons.
>>>
>>> If you can help to test it and note the bugs you find on the issues page 
>>> , that'd be great! Join me and 
>>> the community of Leo enthusiasts in refining LeoJS. Your feedback is 
>>> invaluable in making LeoJS the best it can be.
>>>
>>> 🔗 Get Started: LeoJS Beta 0.2.8 
>>>  (also 
>>> available on open-vsx.org )
>>>
>>> *Many thanks to Edward, Thomas Kevin, and the rest of the Leo community 
>>> for your contributions and support!!*
>>>
>>> Félix
>>>
>>

-- 
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/b1d778f5-0924-45c6-9270-1e739100e5d1n%40googlegroups.com.


Re: Installing nim was easy!

2024-01-02 Thread Thomas Passin
So did I, but at one point my distro called "gcc.exe", so I had to add it 
to the path.

On Tuesday, January 2, 2024 at 5:35:25 AM UTC-5 Edward K. Ream wrote:

> On Monday, January 1, 2024 at 11:05:00 AM UTC-6 Thomas wrote:
>
> How did you install gcc?  Using minGW?
>
>
> where gcc reports  C:\msys64\ucrt64\bin\gcc.exe, so the answer was 
> probably msys2 .
>
> Iirc, I installed this package for use by a music engraving package, maybe 
> LilyPond.
>
> As usual, I did *not* alter the Windows path. Instead, I created *gcc.cmd*, 
> which *is* on the path.
>
> 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/b543f451-f44d-4959-9ad3-f3a755230197n%40googlegroups.com.


Re: ✨LeoJS beta 0.2.8 Released!

2024-01-01 Thread Thomas Passin
So far, so good - it updated and ran in both VSC and VSCodium.

On Monday, January 1, 2024 at 10:38:21 PM UTC-5 Félix wrote:

> 📣Introducing LeoJS Beta 0.2.8
> LeoJS Beta 0.2.8 is here, bringing a substantial update filled with 
> enhancements and critical fixes.
> [image: _56d93bdf-e7f0-4625-85a2-cbf3cfc87fee.jpg]
>
> 🔍What's New in 0.2.8:
>
>- *Help Commands*: 'helpCommands.py' was converted to typescript, 
>enabling help commands.
>- *UNL Support*: Works in log pane, body panes, and all editor windows.
>- *Goto-Script Fix*: Now works seamlessly with @button items.
>- *Markdown*: The @auto markdown importer and writer now ensures 
>flawless read-write integrity.
>- *Undo/Redo for UAs*: Enhanced command support for 'Clear UAs' and 
>'Set UA'.
>- *Clone Related Commands*: Fixes to 'show clone ancestors' and 'show 
>clone parents' commands.
>- *Workspace-Specific Sessions*: Session management is now more 
>personalized with workspace-specific settings.
>- *Stable Node Selection*: LeoJS maintains focus on the selected node 
>when refreshing external files.
>- *gnx-kind Setting*: Choose between uuid, ksuid, or traditional GNX.
>
> 🚀 Continuous Improvements Since Launch:
>
>- Refined tooltips, language coloring support, and bug fixes in 
>various importers.
>- Enhanced keyboard navigation and pattern support for web browsers.
>- Streamlined mobile experience, including 'ConfirmBeforeClose' 
>improvements.
>- Resolved issues with goto-next-clone and goto-next-marked refresh 
>cycles, session management, and body pane labeling.
>- Introduced user-friendly 'Recent Files' icons and buttons.
>
> If you can help to test it and note the bugs you find on the issues page 
> , that'd be great! Join me and 
> the community of Leo enthusiasts in refining LeoJS. Your feedback is 
> invaluable in making LeoJS the best it can be.
>
> 🔗 Get Started: LeoJS Beta 0.2.8 
>  (also 
> available on open-vsx.org )
>
> *Many thanks to Edward, Thomas Kevin, and the rest of the Leo community 
> for your contributions and support!!*
>
> Félix
>

-- 
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/66121423-1dcb-42e8-8189-c59bade01592n%40googlegroups.com.


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-01 Thread Thomas Passin via Python-list

On 1/1/2024 12:26 PM, Mats Wichmann via Python-list wrote:

On 1/1/24 07:11, Thomas Passin via Python-list wrote:

Here's how to find out what program Windows thinks it should use to 
run a ".py" file.  In a console:


C:\Users\tom>assoc .py
.py=Python.File

C:\Users\tom>ftype Python.file
Python.file="C:\Windows\py.exe" "%L" %*


That's not enough. There is now (has been for a while) a layered system, 
and this gives you just one layer, there may be other associations that 
win out.


Per somebody who actually knows:

 > The only way to determine the association without reimplmenting the 
shell's search is to simply ask the shell via AssocQueryString. Possibly 
PowerShell can provide this information. – Eryk Sun


"Possibly", eh?  In fact, on my system those layers must be in effect, 
since ftype claims that the "py" launcher will be used but in actual 
fact the old Python 3.9.9 is used instead, as I wrote earlier.  This is 
verified by this tiny Python script:


# Optional shebang line here
import sys
print(sys.executable)

Then run it with "py", a proposed shebang line, its plain name on the 
command line, whatever.  That will tell you for sure which Python 
executable gets launched by which technique.


On Windows 10, a shebang line gets ignored in favor of Python 3.9.9 (if 
invoked by the script name alone) or Python 3.12.1 (if invoked by the 
"py" launcher).


--
https://mail.python.org/mailman/listinfo/python-list


Re: Installing nim was easy!

2024-01-01 Thread Thomas Passin
In the end, I was able to get the latest version of nim (2.0.2), nimble, 
and koch.  Recall that Windows defender (and various browsers) are not 
allowing the standard zip file from the Nim site to be downloaded.  When I 
compiled Nim another way, the koch executable was deleted by Defender right 
after it was compiled, and the result didn't include nimble.  Here's what 
worked in the end:

I ran a Linux VM and used it to download the Nim zip *for Windows* from the 
Nim site. I unzipped it *on the Linux VM*.  I copied the unzipped tree from 
the VM to my Windows drive - I have a shared directory that lets me do this.

Then (on Windows) I ran the build-all script and it built the Nim 2.02 
compiler.  When it went on to try to build the koch executable, Defender 
deleted it as before.  However, I was able to run the Nim compiler to 
create a nimble executable.  Then I was able to run nimble install nim, 
which rebuilt nim but also succeeded in building koch, which this time 
Defender did not delete.

Apparently the spurious virus warning applies to the version of koch 
compiled by an earlier version of Nim, but not by the latest  version.

Remember, you have to have installed the gcc compiler package, which you 
can get from the Nim GitHub site in the minGW distro.  The reason is that 
earlier versions of Nim were compiled from c code (or maybe c++, I'm not 
sure).  The newer versions can be compiled by the Nim compiler itself.  You 
have to have a working Nim compiler before it can be used to build later 
versions of itself, and that's where the gcc compiler comes in.

On Monday, January 1, 2024 at 2:10:13 PM UTC-5 Thomas Passin wrote:

> I went a different route but didn't get nimble.  I installed minGW from 
> the Nim Github site, then cloned the Nim Github and followed the 
> instructions as given on Nim 
> <https://github.com/nim-lang/nim?tab=readme-ov-file#compiling>.  This 
> gave me Nim 1.9.1.  However, the build script also tries to build koch, and 
> Windows Defender thinks it's malware and deletes it.  That might be the 
> source of the warning for the zip of the binary distro.  According to the 
> instructions, kock is used to further upgrade Nim.  So that won't work.
>
> Also, this distro doesn't build nimble.  I'll go after that next.
>
> On Monday, January 1, 2024 at 10:27:25 AM UTC-5 Edward K. Ream wrote:
>
>> Apparently the malware warnings are spurious: See nim issue #23151 
>> <https://github.com/nim-lang/Nim/issues/23151>.
>>
>> That said, there is no way I would open the .zip file without first 
>> disinfecting it.
>>
>> The Nim install page <https://nim-lang.org/install_windows.html>said to 
>> run finish.exe after unpacking the .zip file. But that file does not exist. 
>> Happily, earlier I had found the Nim Package Directory 
>> <https://nimble.directory/>.
>>
>> I was looking for a python tokenizer, but I noticed the Nim package 
>> <https://nimble.directory/pkg/nim>.
>>
>> To complete the install I just ran nimble install nim from Nim's bin 
>> directory. Everything just worked!
>>
>> Perhaps I got lucky: I had already installed gcc (and added gcc.cmd) so 
>> nimble could invoke gcc even with gcc missing from my Windows path.
>>
>> *Summary*
>>
>> Use nimble install nim to complete the install.
>>
>> I am eager to start playing with Nim!
>>
>> 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/5109c22b-2c55-47e5-a164-9bdddbda064cn%40googlegroups.com.


Re: Installing nim was easy!

2024-01-01 Thread Thomas Passin
I went a different route but didn't get nimble.  I installed minGW from the 
Nim Github site, then cloned the Nim Github and followed the instructions 
as given on Nim 
.  This gave 
me Nim 1.9.1.  However, the build script also tries to build koch, and 
Windows Defender thinks it's malware and deletes it.  That might be the 
source of the warning for the zip of the binary distro.  According to the 
instructions, kock is used to further upgrade Nim.  So that won't work.

Also, this distro doesn't build nimble.  I'll go after that next.

On Monday, January 1, 2024 at 10:27:25 AM UTC-5 Edward K. Ream wrote:

> Apparently the malware warnings are spurious: See nim issue #23151 
> .
>
> That said, there is no way I would open the .zip file without first 
> disinfecting it.
>
> The Nim install page said to 
> run finish.exe after unpacking the .zip file. But that file does not exist. 
> Happily, earlier I had found the Nim Package Directory 
> .
>
> I was looking for a python tokenizer, but I noticed the Nim package 
> .
>
> To complete the install I just ran nimble install nim from Nim's bin 
> directory. Everything just worked!
>
> Perhaps I got lucky: I had already installed gcc (and added gcc.cmd) so 
> nimble could invoke gcc even with gcc missing from my Windows path.
>
> *Summary*
>
> Use nimble install nim to complete the install.
>
> I am eager to start playing with Nim!
>
> 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/34981960-397e-4bb2-8996-1a99b87ec2d8n%40googlegroups.com.


Re: Installing nim was easy!

2024-01-01 Thread Thomas Passin
How did you install gcc?  Using minGW?

On Monday, January 1, 2024 at 10:27:25 AM UTC-5 Edward K. Ream wrote:

> Apparently the malware warnings are spurious: See nim issue #23151 
> .
>
> That said, there is no way I would open the .zip file without first 
> disinfecting it.
>
> The Nim install page said to 
> run finish.exe after unpacking the .zip file. But that file does not exist. 
> Happily, earlier I had found the Nim Package Directory 
> .
>
> I was looking for a python tokenizer, but I noticed the Nim package 
> .
>
> To complete the install I just ran nimble install nim from Nim's bin 
> directory. Everything just worked!
>
> Perhaps I got lucky: I had already installed gcc (and added gcc.cmd) so 
> nimble could invoke gcc even with gcc missing from my Windows path.
>
> *Summary*
>
> Use nimble install nim to complete the install.
>
> I am eager to start playing with Nim!
>
> 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/890b08e8-1334-448d-8b7a-0cfb00fdfee1n%40googlegroups.com.


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-01 Thread Thomas Passin via Python-list

On 1/1/2024 8:19 AM, Thomas Passin via Python-list wrote:

On 1/1/2024 6:02 AM, Sibylle Koczian via Python-list wrote:

Am 30.12.2023 um 04:04 schrieb Mike Dewhirst via Python-list:


I had assumed the OP had installed Python from the Microsoft shop and 
that's where py.exe must have come from.




In fact I didn't say in my post that I always get Python from 
python.org. When I started to use the language there was no Python 
from any Microsoft shop (I'm not sure there was a Microsoft shop, it 
was in the last millenium, Python 1.5 or 1.6). So I tend to forget 
that possible download source.


But in all this thread I didn't see a single explanation for my 
current situation: one and the same shebang line works on Windows 10 / 
Python 3.11 and doesn't work on Windows 11 / Python 3.12. I suspect 
Windows, because a change in the way Python 3.12 uses shebang lines 
should be visible in the documentation.


Happy new year to all!
Sibylle


Happy New Year!

I speculated that the shebang line didn't work on Windows 10 either, but 
you didn't realize it because the file associations were right to launch 
".py" programs with the right version of Python.  When the newer version 
of Python got installed, the default Python program to use, was not 
updated correctly, and the shebang line still has nothing to do with the 
launch failure.  This could happen if other the older install went into 
Program Files, while the newer one went into 
%USERPROFILE%\AppData\Local\Programs\Python.


This was backed up with all of 5 minutes of experimenting on my own 
computer, on which Windows launches ".py" programs with an old install 
of Python 3.9.9, but the py launcher launches Python 3.12 by default.


Since I am avoiding Windows 11, I can't try anything on it, so my 
thoughts above may not be relevant.


The Python docs for 3.12.1 cover shebang lines at

https://docs.python.org/3/using/windows.html

"If the first line of a script file starts with #!, it is known as a 
“shebang” line. Linux and other Unix like operating systems have native 
support for such lines and they are commonly used on such systems to 
indicate how a script should be executed. This launcher allows the same 
facilities to be used with Python scripts on Windows and the examples 
above demonstrate their use.


To allow shebang lines in Python scripts to be portable between Unix and 
Windows, this launcher supports a number of ‘virtual’ commands to 
specify which interpreter to use. The supported virtual commands are:


/usr/bin/env
/usr/bin/python
/usr/local/bin/python
python

For example, if the first line of your script starts with

#! /usr/bin/python
The default Python will be located and used. As many Python scripts 
written to work on Unix will already have this line, you should find 
these scripts can be used by the launcher without modification. If you 
are writing a new script on Windows which you hope will be useful on 
Unix, you should use one of the shebang lines starting with /usr."


But

"The /usr/bin/env form of shebang line has one further special property. 
Before looking for installed Python interpreters, this form will search 
the executable PATH for a Python executable matching the name provided 
as the first argument. This corresponds to the behaviour of the Unix env 
program, which performs a PATH search. If an executable matching the 
first argument after the env command cannot be found, but the argument 
starts with python, it will be handled as described for the other 
virtual commands. The environment variable PYLAUNCHER_NO_SEARCH_PATH may 
be set (to any value) to skip this search of PATH.


Shebang lines that do not match any of these patterns are looked up in 
the [commands] section of the launcher’s .INI file. This may be used to 
handle certain commands in a way that makes sense for your system. The 
name of the command must be a single argument (no spaces in the shebang 
executable), and the value substituted is the full path to the 
executable (additional arguments specified in the .INI will be quoted as 
part of the filename)."




Here's how to find out what program Windows thinks it should use to run 
a ".py" file.  In a console:


C:\Users\tom>assoc .py
.py=Python.File

C:\Users\tom>ftype Python.file
Python.file="C:\Windows\py.exe" "%L" %*

If your ".py" files are associated to the py.exe launcher, as mine are, 
then the launcher may try to use your shebang line and you need to make 
sure there aren't any spaces where there shouldn't be.


If your ".py" files are not associated with py.exe, the shebang line 
probably won't be used for anything.



--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-01 Thread Thomas Passin via Python-list

On 1/1/2024 6:02 AM, Sibylle Koczian via Python-list wrote:

Am 30.12.2023 um 04:04 schrieb Mike Dewhirst via Python-list:


I had assumed the OP had installed Python from the Microsoft shop and 
that's where py.exe must have come from.




In fact I didn't say in my post that I always get Python from 
python.org. When I started to use the language there was no Python from 
any Microsoft shop (I'm not sure there was a Microsoft shop, it was in 
the last millenium, Python 1.5 or 1.6). So I tend to forget that 
possible download source.


But in all this thread I didn't see a single explanation for my current 
situation: one and the same shebang line works on Windows 10 / Python 
3.11 and doesn't work on Windows 11 / Python 3.12. I suspect Windows, 
because a change in the way Python 3.12 uses shebang lines should be 
visible in the documentation.


Happy new year to all!
Sibylle


Happy New Year!

I speculated that the shebang line didn't work on Windows 10 either, but 
you didn't realize it because the file associations were right to launch 
".py" programs with the right version of Python.  When the newer version 
of Python got installed, the default Python program to use, was not 
updated correctly, and the shebang line still has nothing to do with the 
launch failure.  This could happen if other the older install went into 
Program Files, while the newer one went into 
%USERPROFILE%\AppData\Local\Programs\Python.


This was backed up with all of 5 minutes of experimenting on my own 
computer, on which Windows launches ".py" programs with an old install 
of Python 3.9.9, but the py launcher launches Python 3.12 by default.


Since I am avoiding Windows 11, I can't try anything on it, so my 
thoughts above may not be relevant.


The Python docs for 3.12.1 cover shebang lines at

https://docs.python.org/3/using/windows.html

"If the first line of a script file starts with #!, it is known as a 
“shebang” line. Linux and other Unix like operating systems have native 
support for such lines and they are commonly used on such systems to 
indicate how a script should be executed. This launcher allows the same 
facilities to be used with Python scripts on Windows and the examples 
above demonstrate their use.


To allow shebang lines in Python scripts to be portable between Unix and 
Windows, this launcher supports a number of ‘virtual’ commands to 
specify which interpreter to use. The supported virtual commands are:


/usr/bin/env
/usr/bin/python
/usr/local/bin/python
python

For example, if the first line of your script starts with

#! /usr/bin/python
The default Python will be located and used. As many Python scripts 
written to work on Unix will already have this line, you should find 
these scripts can be used by the launcher without modification. If you 
are writing a new script on Windows which you hope will be useful on 
Unix, you should use one of the shebang lines starting with /usr."


But

"The /usr/bin/env form of shebang line has one further special property. 
Before looking for installed Python interpreters, this form will search 
the executable PATH for a Python executable matching the name provided 
as the first argument. This corresponds to the behaviour of the Unix env 
program, which performs a PATH search. If an executable matching the 
first argument after the env command cannot be found, but the argument 
starts with python, it will be handled as described for the other 
virtual commands. The environment variable PYLAUNCHER_NO_SEARCH_PATH may 
be set (to any value) to skip this search of PATH.


Shebang lines that do not match any of these patterns are looked up in 
the [commands] section of the launcher’s .INI file. This may be used to 
handle certain commands in a way that makes sense for your system. The 
name of the command must be a single argument (no spaces in the shebang 
executable), and the value substituted is the full path to the 
executable (additional arguments specified in the .INI will be quoted as 
part of the filename)."



--
https://mail.python.org/mailman/listinfo/python-list


Re: mypy question

2023-12-30 Thread Thomas Passin via Python-list

On 12/30/2023 9:14 AM, Thomas Passin via Python-list wrote:

On 12/29/2023 10:02 AM, Karsten Hilbert via Python-list wrote:

I agree that mypy's grasp of my intent from

queries:list[dict[str, str | list | dict[str, Any]]]=None,

into

"List[Dict[str, Union[str, List[Any], Dict[str, Any"

seems accurate. I just don't understand why list[dict[str,
str]] should not pass that construct.


I made a tiny test program with your type signature, and got this error 
message from mypy:


c:\temp\python\typing_test.py:3: error: X | Y syntax for unions requires 
Python 3.10  [syntax]


Aside from that, this variation causes no mypy error (you must use 
Sequence instead of List), and is also more clear about what you are 
trying to get:


from typing import Union, Sequence, Dict

DictType1 = Dict[str, str]
DictType2 = Dict[str, Sequence]
DictType3 = Dict[str, Dict]
QueryType = Sequence[Union[DictType1, DictType2, DictType3]]

def test_typing(queries:QueryType=None):
     print(type(queries))

d1 = {'k1': 'v1', 'k2': 'v2'}
queries = [d1,]
test_typing(queries)

I'm not sure if this captures exactly what you want, but it avoids the 
problem where mypy does not regard str and Union[str, list] as 
equivalent types.  I tested this using Python 3.12.


In doing more testing, I have learned that my suggestion above does 
work, *except* that you cannot mix-and-match different DictTypex types 
within the same Sequence - meaning within the same query argument.  Any 
of the Union types is OK but they all have to be the same in any instance.


--
https://mail.python.org/mailman/listinfo/python-list


Re: mypy question

2023-12-30 Thread Thomas Passin via Python-list

On 12/29/2023 10:02 AM, Karsten Hilbert via Python-list wrote:

Am Fri, Dec 29, 2023 at 07:49:17AM -0700 schrieb Mats Wichmann via Python-list:


I am not sure why mypy thinks this

gmPG2.py:554: error: Argument "queries" to "run_rw_queries" has incompatible type 
"List[Dict[str, str]]"; expected
"List[Dict[str, Union[str, List[Any], Dict[str, Any"  [arg-type]
 rows, idx = run_rw_queries(link_obj = conn, queries = 
queries, return_data = True)
   
^~~

should be flagged. The intent is for "queries" to be

a list
of dicts
with keys of str
and values of
str OR
list of anything OR
dict with
keys of str
and values of anything

I'd have thunk list[dict[str,str]] matches that ?


Dict[str, str] means the key type and value type should both be strings,


Indeed, I know that much, list[dict[str, str]] is what is getting
passed in in this particular invocation of run_rw_queries().

For what it's worth here's the signature of that function:

def run_rw_queries (
link_obj:_TLnkObj=None,
queries:list[dict[str, str | list | dict[str, Any]]]=None,
end_tx:bool=False,
return_data:bool=None,
get_col_idx:bool=False,
verbose:bool=False
) -> tuple[list[dbapi.extras.DictRow], dict[str, int] | None]:

Given that I would have thought that passing in
list[dict[str, str]] for "queries" ought to be type safe.
Mypy indicates otherwise which I am not grokking as to why.


but in your
retelling above you indicate lots of possible value types... actually the mypy 
guess
seems to be a pretty good recreation of your psuedo-code description.


I agree that mypy's grasp of my intent from

queries:list[dict[str, str | list | dict[str, Any]]]=None,

into

"List[Dict[str, Union[str, List[Any], Dict[str, Any"

seems accurate. I just don't understand why list[dict[str,
str]] should not pass that construct.


Maybe better to ask the mypy people directly.


Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B


--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: mypy question

2023-12-30 Thread Thomas Passin via Python-list

On 12/30/2023 10:08 AM, Karsten Hilbert via Python-list wrote:

Dear Thomas,

thanks for taking the time to look into my issue.

Maybe it helps if I explain what I want (sorry that my web mailer does not 
respect
indentation, I will insert dots).

I want a function to run SQL queries:

run_queries(conn, queries):
...for q in queries:
..conn.execute(q)

I now want to add type hints such that my large codebase can
be checked for silly doings. First, queries is to be a list
of the SQL to run:

run_queries(conn, queries:list):

Then, each list entry can be

...a string holding simple, complete SQL (say "SELECT 1")

run_queries(conn, queries:list[str]):


It occurs to me that you could simplify things if you converted those 
plain query strings to dicts:


'SELECT 1' --> {'SQL': 'SELECT 1'}

I'm fairly sure your database queries don't actually give you strings or 
dicts, right?  You probably get lists (or iterators) of tuples and 
somewhere you convert them to the arguments you are feeding to 
run_queries().  At least, that is how the standard Python db adapters 
work. If you change that conversion step, your arguments to 
run_queries() will all be lists of dicts, making your code simpler and 
reducing the complexity of the type hints.



or

...a dict holding the SQL and arguments for parameters

run_queries(conn, queries:list[dict]):

So, taken together:

run_queries(conn, queries:list[str|dict]):

(yes, this is in Python 3.11/3.12)

Now, when it is a list of dicts I want to further constrain the
dicts. Each is to contain the keys "SQL" and "args". So the keys
are of type str. The values for the keys will be of various types,
such that I chose Any as pseudo-type, so that each list entry that
is of type dict should be dict[str, Any], hence:

queries = [{'SQL': 'SELECT %(value)s', 'args': {'value': 1}}]

and

run_queries(conn, queries:list[str|dict[str, Any]]):

If I now call this function with a simple SQL query:

SQL_query = 'SELECT 1'  # should be type str ?
queries = [SQL_query]   # should be type list[str] ?
run_queries(conn, queries = queries)

and run mypy over that (at least inside my complex codebase) I will
get a type mismatch being hinted at.

So far I don't grasp at which point my reasoning above is faulty.

Karsten


--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: mypy question

2023-12-30 Thread Thomas Passin via Python-list

On 12/30/2023 10:08 AM, Karsten Hilbert via Python-list wrote:

Dear Thomas,

thanks for taking the time to look into my issue.

Maybe it helps if I explain what I want (sorry that my web mailer does not 
respect
indentation, I will insert dots).

I want a function to run SQL queries:

run_queries(conn, queries):
...for q in queries:
..conn.execute(q)

I now want to add type hints such that my large codebase can
be checked for silly doings. First, queries is to be a list
of the SQL to run:

run_queries(conn, queries:list):

Then, each list entry can be

...a string holding simple, complete SQL (say "SELECT 1")

run_queries(conn, queries:list[str]):

or

...a dict holding the SQL and arguments for parameters

run_queries(conn, queries:list[dict]):

So, taken together:

run_queries(conn, queries:list[str|dict]):

(yes, this is in Python 3.11/3.12)

Now, when it is a list of dicts I want to further constrain the
dicts. Each is to contain the keys "SQL" and "args". So the keys
are of type str. The values for the keys will be of various types,
such that I chose Any as pseudo-type, so that each list entry that
is of type dict should be dict[str, Any], hence:

queries = [{'SQL': 'SELECT %(value)s', 'args': {'value': 1}}]

and

run_queries(conn, queries:list[str|dict[str, Any]]):

If I now call this function with a simple SQL query:

SQL_query = 'SELECT 1'  # should be type str ?
queries = [SQL_query]   # should be type list[str] ?
run_queries(conn, queries = queries)

and run mypy over that (at least inside my complex codebase) I will
get a type mismatch being hinted at.

So far I don't grasp at which point my reasoning above is faulty.

Karsten


I am not very expert in Python type hints.  In working up the example 
program I just posted, I got an error message from mypy that remarked 
that "list" is invariant, and to try Sequence which is "covariant".  I 
don't know what that means (and I haven't looked into it yet), but when 
I changed from list to Sequence as suggested, mypy stopped complaining.


Here is the exact error message, and it has a reference you might want 
to follow up with:


c:\temp\python\typing_test.py:16: note: "List" is invariant -- see 
https://mypy.readthedocs.io/en/stable/common_issues.html#variance
c:\temp\python\typing_test.py:16: note: Consider using "Sequence" 
instead, which is covariant


Before that, mypy insisted that str and Union[str, list] were 
incompatible argument types, which is something you are seeing, too.


I suggest that you build up your types as in my example, so that it's 
very clear what they are and very easy to change them, and use Sequence 
instead of List (or list).  See if that will do the job.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Issue #3710: EKR's last lecture

2023-12-30 Thread Thomas Passin
Looks like Nim can use a good range of scientific computing libraries, and 
there are some GUI libraries.  So at this point the two compiled languages 
that would be if serious interest to me would be Nim and Julia.

On Saturday, December 30, 2023 at 2:26:06 AM UTC-5 Edward K. Ream wrote:

> On Sat, Dec 30, 2023 at 12:15 AM Edward K. Ream  wrote
>
> So yes, I would use nim if I could.
>>
>> I've just glanced at nim code.  "I" instead of "if"??
>>
>
> Never mind. nim's intro page clearly shows python-like keywords. 
>
> I thought I was reading nim code at https://rosettacode.org/wiki, but I 
> must have been reading something else :-)
>
> 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/643c36d7-6002-4a21-9b04-6537e4bf8692n%40googlegroups.com.


Re: mypy question

2023-12-30 Thread Thomas Passin via Python-list

On 12/29/2023 10:02 AM, Karsten Hilbert via Python-list wrote:

I agree that mypy's grasp of my intent from

queries:list[dict[str, str | list | dict[str, Any]]]=None,

into

"List[Dict[str, Union[str, List[Any], Dict[str, Any"

seems accurate. I just don't understand why list[dict[str,
str]] should not pass that construct.


I made a tiny test program with your type signature, and got this error 
message from mypy:


c:\temp\python\typing_test.py:3: error: X | Y syntax for unions requires 
Python 3.10  [syntax]


Aside from that, this variation causes no mypy error (you must use 
Sequence instead of List), and is also more clear about what you are 
trying to get:


from typing import Union, Sequence, Dict

DictType1 = Dict[str, str]
DictType2 = Dict[str, Sequence]
DictType3 = Dict[str, Dict]
QueryType = Sequence[Union[DictType1, DictType2, DictType3]]

def test_typing(queries:QueryType=None):
print(type(queries))

d1 = {'k1': 'v1', 'k2': 'v2'}
queries = [d1,]
test_typing(queries)

I'm not sure if this captures exactly what you want, but it avoids the 
problem where mypy does not regard str and Union[str, list] as 
equivalent types.  I tested this using Python 3.12.




--
https://mail.python.org/mailman/listinfo/python-list


Re: 🚀 LeoInteg 1.0.17 Released

2023-12-29 Thread Thomas Passin
As a first response to overcoming Viktor's problem, I suggest that Felix 
could find a way to have LeoInteg open a venv and launch Python from that.  
This would require a new setting that would take priority over the current 
setting for the Python executable. (Sorry, Felix, I hate to suggest more 
work for you!).  Leo integ would have to run the venv activation  script 
and launch the bridge in that environment.  I don't know how to do that but 
I imagine it's possible. Once launched, LeoInteg would not need to know 
about the venv any more to communicate with the bridge.

This way, a user could follow the suggestion in the warning message from 
pip by creating a venv and installing Leo into it.

On Friday, December 29, 2023 at 8:52:13 AM UTC-5 Thomas Passin wrote:

> On Friday, December 29, 2023 at 8:49:18 AM UTC-5 Edward K. Ream wrote:
>
> On Fri, Dec 29, 2023 at 7:35 AM Thomas Passin wrote: 
>
> > I may be one of the few people who realizes how inconsistent the 
> installation situation is because I run around 8 or 10 different distros 
> and distro versions from time to time to make sure a certain software 
> package runs right on Linux. 
>
> I'm glad we have you as our resident guru.
>
>
> Far from a guru!  I suppose I'm not really a newbie any more, but I'm 
> still stumbling around. 
>

-- 
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/f9fb1f3e-f384-40c6-82d4-b36a927e815dn%40googlegroups.com.


Re: 🚀 LeoInteg 1.0.17 Released

2023-12-29 Thread Thomas Passin

On Friday, December 29, 2023 at 8:49:18 AM UTC-5 Edward K. Ream wrote:

On Fri, Dec 29, 2023 at 7:35 AM Thomas Passin wrote: 

> I may be one of the few people who realizes how inconsistent the 
installation situation is because I run around 8 or 10 different distros 
and distro versions from time to time to make sure a certain software 
package runs right on Linux. 

I'm glad we have you as our resident guru.


Far from a guru!  I suppose I'm not really a newbie any more, but I'm still 
stumbling around. 

-- 
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/b00ae735-9397-4fa5-b87b-87c983fc23f2n%40googlegroups.com.


Re: 🚀 LeoInteg 1.0.17 Released

2023-12-29 Thread Thomas Passin
I may be one of the few people who realizes how inconsistent the 
installation situation is because I run around 8 or 10 different distros 
and distro versions from time to time to make sure a certain software 
package runs right on Linux.  Naturally I try to install Leo and GF4 on 
those distros.  So I have exposure to a wider potential range of problems 
than most people. 

Unfortunately for wrangling these issues you really need to set up new VMs 
each time since once you get, say, Leo working then updating is usually 
easier.  It can all be very time consuming.

On Friday, December 29, 2023 at 8:26:39 AM UTC-5 Thomas Passin wrote:

> On Friday, December 29, 2023 at 6:37:55 AM UTC-5 Edward K. Ream wrote:
>
> On Fri, Dec 29, 2023 at 3:44 AM Viktor Ransmayr  
> wrote:
>
>
> tbp1...@gmail.com schrieb am Freitag, 29. Dezember 2023 um 00:54:50 UTC+1:
>
> You referring to needing to use *--break-system-packages*, is that right? 
>
>
> Big sigh. Another example of a Python "improvement" breaking existing code 
> or practices.
>
> Thomas, is this a documentation issue for Leo, or must setup.py change?
>
>
> I don't know; I'll have to think about it some more.  I just encountered 
> these new messages from pip in the last week or so, not in connection with 
> leoInteg but when trying to update Leo on one or another Linux VMs.  I 
> assumed it was a special modification by the Distro packagers and didn't 
> realize it was the result of a new PEP.
>
> For LeoInteg one can point it to any Python executable you want, so the 
> answer would be to install another parallel version of Python and use 
> that.  This would in fact also apply to Leo updates outside of LeoInteg.  
> But installing another Python version that's not supplied by the distro's 
> packager is going to be a problem for many users, and sometimes doesn't go 
> smoothly.  Even after you get another Python version installed, whether Leo 
> will install and work varies across distros.  Some of them require you to 
> install some requirement using the distro's package manager.  Some of them 
> don't supply a certain shared library (.so file) and you have to track down 
> which one it is and how to install it.  It's a mess.  I bump up against 
> similar problems with my GF4 package, usually in connection with tkinter or 
> matplotlib.
>
> I suppose we should do something but I can't see what it would be that 
> would work across all distros.
>

-- 
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/b09ee4a6-4d57-4cc4-b79d-c0034585dca3n%40googlegroups.com.


Re: 🚀 LeoInteg 1.0.17 Released

2023-12-29 Thread Thomas Passin

On Friday, December 29, 2023 at 6:37:55 AM UTC-5 Edward K. Ream wrote:

On Fri, Dec 29, 2023 at 3:44 AM Viktor Ransmayr  
wrote:


tbp1...@gmail.com schrieb am Freitag, 29. Dezember 2023 um 00:54:50 UTC+1:

You referring to needing to use *--break-system-packages*, is that right? 


Big sigh. Another example of a Python "improvement" breaking existing code 
or practices.

Thomas, is this a documentation issue for Leo, or must setup.py change?


I don't know; I'll have to think about it some more.  I just encountered 
these new messages from pip in the last week or so, not in connection with 
leoInteg but when trying to update Leo on one or another Linux VMs.  I 
assumed it was a special modification by the Distro packagers and didn't 
realize it was the result of a new PEP.

For LeoInteg one can point it to any Python executable you want, so the 
answer would be to install another parallel version of Python and use 
that.  This would in fact also apply to Leo updates outside of LeoInteg.  
But installing another Python version that's not supplied by the distro's 
packager is going to be a problem for many users, and sometimes doesn't go 
smoothly.  Even after you get another Python version installed, whether Leo 
will install and work varies across distros.  Some of them require you to 
install some requirement using the distro's package manager.  Some of them 
don't supply a certain shared library (.so file) and you have to track down 
which one it is and how to install it.  It's a mess.  I bump up against 
similar problems with my GF4 package, usually in connection with tkinter or 
matplotlib.

I suppose we should do something but I can't see what it would be that 
would work across all distros.

-- 
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/8d143555-f516-4b99-a628-fda6bf5b54c9n%40googlegroups.com.


Re: 🚀 LeoInteg 1.0.17 Released

2023-12-28 Thread Thomas Passin
You referring to needing to use *--break-system-packages*, is that right? I 
don't see this as a Leo issue.  You are installing Leo into the system's 
Python install, and the OS is touchy about that.  Some package that the OS 
relies on might get updated in an incompatible way as part of the 
installation of Leo, but the system can't know if that will happen.  So it 
prefers not to install some Python packages.  I have seen the same warning 
myself when trying to install or upgrade certain packages.  I can't 
remember which ones, though.

I didn't even know there was a  *-break-system-packages option. *But it's 
probably not a good idea to use it unless you have some reason to know that 
it would not harm the system.  Overall, a venv would be safer, or, as I 
generally have done, install a different Python version from the system's 
and use that for everything you want to do.

On Thursday, December 28, 2023 at 4:01:20 PM UTC-5 viktor@gmail.com 
wrote:

Hello Felix, hello Edward,
[snip]

Shall I create a LeoInteg - or - Leo issue for it ?

With kind regards,

Viktor
 

-- 
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/a5629465-8c1f-46da-8cca-0a2db74770bdn%40googlegroups.com.


Re: (share a post)Working With Discovery Trees

2023-12-27 Thread Thomas Passin
Here are two examples of genealogy trees I created with Leo scripts.  The 
data is stored in a Leo outline that uses my Zettelkasten system.  For the 
family history I used a few extra conventions for the keys of data items.  
One type of diagram is created  using Graphviz, for the other my script 
creates the svg itself.

These diagrams display with VR3.  For leoLS I imagine one would want to 
display diagrams in a new tab.

On Wednesday, December 27, 2023 at 12:08:46 PM UTC-5 Edward K. Ream wrote:

> On Wed, Dec 27, 2023 at 10:36 AM HaveF HaveF  wrote:
>
>> There are a number of text-to-diagram tools that can potentially produce 
>>> diagrams like these.  Some of them are Graphviz, Plantuml, and d2.  I know 
>>> there are others.  I have been able to use Graphviz to produce a 
>>> line-of-descent diagram from a Leo outline of family history trees.
>>>
>>
>> I believe it is very easy to implement this in LeoJS. Tons of javascript 
>> lib, like React Flow .
>>
>
> That is my opinion too, but I'm no expert.
>
> 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/43504ee2-c86b-499f-bf31-de1164407a79n%40googlegroups.com.


http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";>





http://www.w3.org/2000/svg"; xmlns:xlink="http://www.w3.org/1999/xlink";>



G







Gret 1-Zelickson



Gret 1-Zelickson







Andreas Gret 2



Andreas Gret 2







Gret 1-Zelickson->Andreas Gret 2





child-of







Andreas Gret 1



Andreas Gret 1







Andreas Gret 1->Gret 1-Zelickson





spouse







Sylvia Zelickson



Sylvia Zelickson







Sylvia Zelickson->Gret 1-Zelickson





spouse







Gret 2 - Mary [Unknown]



Gret 2 - Mary [Unknown]







John Crate



John Crate







Gret 2 - Mary [Unknown]->John Crate





child-of







Andreas Gret 2->Gret 2 - Mary [Unknown]





spouse







Mary [Unknown]



Mary [Unknown]







Mary [Unknown]->Gret 2 - Mary [Unknown]





spouse







Crate-Seifert



Crate-Seifert







Philip Crate



Philip Crate







Crate-Seifert->Philip Crate





child-of







Mary Seifert



Mary Seifert







Mary Seifert->Crate-Seifert





spouse







John Crate->Crate-Seifert





spouse







Crate-Reisinger



Crate-Reisinger







Barbara Esther Crate



Barbara Esther Crate







Crate-Reisinger->Barbara Esther Crate





child-of







Elizabeth Reisinger



Elizabeth Reisinger







Elizabeth Reisinger->Crate-Reisinger





spouse







Philip Crate->Crate-Reisinger





spouse







Brinkey-Schmaeder



Brinkey-Schmaeder







Dorothy Brinkley



Dorothy Brinkley







Brinkey-Schmaeder->Dorothy Brinkley





child-of







Edward Brinkley



Edward Brinkley







Edward Brinkley->Brinkey-Schmaeder





spouse







Isabelle Schmaeder



Isabelle Schmaeder







Isabelle Schmaeder->Brinkey-Schmaeder





spouse







Fiscus-Brinkley



Fiscus-Brinkley







Fiscus-Brinkley->Edward Brinkley





child-of







Martha J. Fiscus



Martha J. Fiscus







Martha J. Fiscus->Fiscus-Brinkley





spouse







Albinus F. Brinkley



Albinus F. Brinkley







Albinus F. Brinkley->Fiscus-Brinkley





spouse







Fiscus-Crate



Fiscus-Crate







James Fiscus



James Fiscus







Fiscus-Crate->James Fiscus





child-of







Barbara Esther Crate->Fiscus-Crate





spouse







John Fiscus I



John Fiscus I







John Fiscus I->Fiscus-Crate





spouse







Fiscus-Jones



Fiscus-Jones







Fiscus-Jones->Martha J. Fiscus





child-of







James Fiscus->Fiscus-Jones





spouse







Martha Jones



Martha Jones







Martha Jones->Fiscus-Jones





spouse







Collins-Caulfield



Collins-Caulfield







William Collins



William Collins







Collins-Caulfield->William Collins





child-of







John Collins 2



John Collins 2







John Collins 2->Collins-Caulfield





spouse







Collins-King



Collins-King







John Collins 1



John Collins 1







Collins-King->John Collins 1





child-of







William Collins->Collins-King





spouse







Collins-Unknown [1]



Collins-Unknown [1]







Joseph Collins



Joseph Collins







Collins-Unknown [1]->Joseph Collins





child-of







Unknown [1]



Unknown [1]







Unknown [1]->Collins-Unknown [1]





spouse







John Collins 1->Collins-Unknown [1]





spouse







Collins-Lewis



Collins-Lewis







Susanna Collins



Susanna Collins







Collins-Lewis->Susanna Collins





child-of







Joseph Collins->Collins-Lewis





spouse







Susanna Lewis



Susanna Lewis







Susanna Lewis->Collins-Lewis





spouse







Gholson-Hawkins



Gholson-Hawkins







William Gholson Sr



William Gholson Sr







Gholson-Hawkins->William Gholson Sr





child

Re: (share a post)Working With Discovery Trees

2023-12-27 Thread Thomas Passin
There are a number of text-to-diagram tools that can potentially produce 
diagrams like these.  Some of them are Graphviz, Plantuml, and d2.  I know 
there are others.  I have been able to use Graphviz to produce a 
line-of-descent diagram from a Leo outline of family history trees.

On Wednesday, December 27, 2023 at 10:44:20 AM UTC-5 Edward K. Ream wrote:

> On Tue, Dec 26, 2023 at 11:40 AM Thomas Passin  wrote:
>
>> It's a nice way to display and balance out key information.  The 
>> organization is basically parents and children.  I didn't see any examples 
>> where a node had more than one parent.  That means the diagram could be 
>> stored in a standard Leo tree.  As usual, the hard part is creating a 
>> layout of the diagram.
>>
>> The metadata - phase, ticket number, assignees, etc, could be stored in a 
>> node's UAs, or the way I've adopted, with tagged lines in the node's body.  
>> But probably all that data will usually come from a database.
>>
>
> Thanks for these ideas. My first thought was to look in vs-code. Searching 
> plugins using "tree" gives lots of results, but none seem directly 
> applicable.
>
> Looking around the demo page 
> <https://app.mural.co/t/industriallogic9109/m/industriallogic9109/1652365224808/45156490f5e94897dae8ec507461d19e5797a071?sender=u43adf1f95af7b58911e42493>
>  
> with F11 was another idea :-)
>
> 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/de15bb7b-2e94-4d02-90ed-d1e7d7b947cen%40googlegroups.com.


Re: how to write tests in Leo?

2023-12-26 Thread Thomas Passin
I don't have much understanding of Leo's tests myself.  I think that your 
case 1 would be handled by opening a NullGui.  This will give you a working 
g, from which you can access a lot of Leo's functionality.  I'm not sure 
how to deal with getting a commander with a null gui.  But there must be 
some test in Leo's source tree that could be a model.

For example, in leo/unittests/core, I see a file *test_leoColorizer.py*. It 
has a class *TestColorizer(LeoUnitTest)*, which includes:

from leo.core import leoGlobals as g
from leo.core.leoTest2 import LeoUnitTest
from leo.core.leoQt import Qt
import leo.core.leoColorizer as leoColorizer
# ...
"""Test cases for leoColorizer.py"""
def color(self, language_name, text):
"""Run the test by colorizing a node with the given text."""
c = self.c
c.p.b = text.replace('> >', '>>').replace('< <', '<<')
c.recolor_now()

Looking in LeoPyRef for the base class *LeoUnitTest,* I find it in 
*leoTest2.py*. When I run py -m pytest in Leo's top directory, it runs all 
these many tests but does I never see a visible Leo window.  So in those 
unit test files are all the techniques to do what you want.
On Tuesday, December 26, 2023 at 10:09:35 PM UTC-5 iamap...@gmail.com wrote:

> Take a look in the *leo-editor\leo\unittests* directory.  For example, 
>> *test_gui.py* imports g. etc.  Maybe that will be enough to get started.
>>
> My intuitive thought is that there are two types of tests in Leo,
>>>
>>>
>>> 1. Testing of common Python function script nodes,
>>>
>>>
>>> 2. Tests that require a Leo context, such as g, c, p, etc.
>>>
>>> 2.1 Test with Leo already open, because there are already g, c, p
>>>
>>> 2.2 Testing without Leo open. It is no different from a normal 
>>> python program. e.g. 'python -m unittest'
>>>
>>>
>>> Thanks, Thomas, I checked, but failed to understand, that is for 2.2 
> scene, right?
>
> My main question is about 1, and 2.1 scenarios. How to perform specific 
> operations in Leo, not how the code should be written
>
>

-- 
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/5d08771e-ff5f-4ba6-833d-0a4d5f04eb54n%40googlegroups.com.


Re: how to write tests in Leo?

2023-12-26 Thread Thomas Passin
Take a look in the *leo-editor\leo\unittests* directory.  For example, 
*test_gui.py* imports g. etc.  Maybe that will be enough to get started.

On Tuesday, December 26, 2023 at 9:44:46 PM UTC-5 iamap...@gmail.com wrote:

> Hello, there,
>
> My intuitive thought is that there are two types of tests in Leo,
>
>
> 1. Testing of common Python function script nodes,
>
>
> 2. Tests that require a Leo context, such as g, c, p, etc.
>
> 2.1 Test with Leo already open, because there are already g, c, p
>
> 2.2 Testing without Leo open. It is no different from a normal python 
> program. e.g. 'python -m unittest'
>
>
> For 1, if I have such a Leo script node, can I test it?
>
>
> ```
> def add(a, b):
> return a + b
>
> import unittest
> class TestAddFunction(unittest.TestCase):
>
> def test_add(self):
> self.assertEqual(add(1, 2), 3)
> self.assertEqual(add(-1, 1), 0)
> self.assertEqual(add(-1, -1), -2)
> ```
>
>
> For 2, Is this possible for the case in 2.1?
>
>
> I flipped through the posts in the forums and it looked like there should 
> be a 'test-' command, but I only had 'test-one' in my environment, nothing 
> else. `execute-pytest` command also not works(maybe I am doing something 
> wrong)
>
>
> I failed to find anything in the documentation that made me start. Am I 
> doing something wrong?
>
>
>
> Thanks!
>

-- 
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/1ed02ad0-0ae8-4f6e-8d7f-266a2fc8e678n%40googlegroups.com.


Re: (share a post)Working With Discovery Trees

2023-12-26 Thread Thomas Passin
It's a nice way to display and balance out key information.  The 
organization is basically parents and children.  I didn't see any examples 
where a node had more than one parent.  That means the diagram could be 
stored in a standard Leo tree.  As usual, the hard part is creating a 
layout of the diagram.

The metadata - phase, ticket number, assignees, etc, could be stored in a 
node's UAs, or the way I've adopted, with tagged lines in the node's body.  
But probably all that data will usually come from a database.

On Tuesday, December 26, 2023 at 11:17:20 AM UTC-5 iamap...@gmail.com wrote:

> https://www.industriallogic.com/blog/discovery-trees/
>
> The node structure is like Leo(or any mindmap tools), but display in graph 
> and vertical way.
>
>
> The nodes in the graph similar Leo's normal nodes or marked nodes.
>
>
> Interesting
>

-- 
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/0728f38f-2784-40ed-932c-54e94d58c9ban%40googlegroups.com.


Re: LeoJS: What is the equivalent of LeoPyRef.leo?

2023-12-24 Thread Thomas Passin
Thanks, Felix.  Now if we wanted to test out a code modification or 
addition, how would we incorporate that into an extension that VSC could 
load or install?

On Sunday, December 24, 2023 at 12:15:08 PM UTC-5 Félix wrote:

> Hi Thomas, 
>
> Great question -- Thanks for asking!
>
> Since LeoJS is a VSCode (or vscodium) extension, its source code is 
> compiled/minified somehow, and many other source files are omitted from the 
> final 'distribution' package.
>
> Therefore, the way to open and view LeoJS source files (or browse it's *Leo 
> source file* in Leo/LeoJS) is to clone the repo from 
> https://github.com/boltex/leojs, and look at the base of the project 
> folder for *leojs.leo. *
>
> [image: screen.png]
>
> This would be the equivalent of LeoPyRef.leo. (and if you're looking for 
> the equivalent of the base setting file, leoSettings.leo, its at the same 
> place, and named *leojsSettings.leojs*.
>
> Hope this helps! 🦁
>
> Félix
>
>
> On Saturday, December 23, 2023 at 10:54:43 PM UTC-5 tbp1...@gmail.com 
> wrote:
>
>> IOW, where or how do we look at Leo's code? Locations like *g.app.leoDir* 
>> are undefined.
>
>

-- 
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/88cd0619-692a-4935-9c08-a41bfd693bb2n%40googlegroups.com.


Re: question about code organization issues for personal common libraries and multiple plug-ins

2023-12-24 Thread Thomas Passin

On Sunday, December 24, 2023 at 5:50:42 AM UTC-5 Edward K. Ream wrote:


- Define a shared @command f1 node in your myLeoSetting.leo for your 
function f1.
- Execute the function with: c.doCommandByName("f1").


That's how most of my custom things work. 

-- 
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/cf384670-1adc-4dc9-839a-cf09cc240185n%40googlegroups.com.


Re: question about code organization issues for personal common libraries and multiple plug-ins

2023-12-23 Thread Thomas Passin
I don't have a large objection to creating a plugin.  One thing you will 
have to decide is where the plugin should live.  You don't want it to be in 
the Leo codebase since it's personal.  Leo will load plugins from  sys.path 
if you list them in the @enabled-plugins setting if you give the module 
name without the ".py" extension.  So you have to get your plugin on 
sys.path.  Here is how I do it (using Windows paths).  In *Lib.sitepackages 
*I place a .pth file, *custom.pth*. This file walks up the the Python 
directory in %APPDATA%\Python:

# Look in AppData\Roaming\Python for other files and packages.
..\..\

In this Python directory I created *pycustomize\leo.* Now I can import a 
module from that directory:

from pycustomize.leo import my_plugin

I decided to set up the location of these files (I have some others in 
*pycustomizeI*) like this so they wouldn't need to be copied to each new 
Python install.  I only need to remember to copy *custom.pth* to the new 
install.

I recently wrote a tiny test plugin that can install scripts and functions 
(see, I've just been teaching myself how to do the same things you are 
asking about).  In this case I was monkeypatching the g.openUNLFile() method
. Here's its contents:

"""A Leo plugin to run scripts at startup.

Methods changed by this plugin:
- g.openUNLFile()
"""
import leo.core.leoGlobals as g

def new_open_unl(c, s):
print('the new openUNLFile', s, c)
return g.old_openUNLFile(c, s)

def onCreate(tag, keywords):
pass
def init():
"""Return True if the plugin has loaded successfully."""
if g.unitTesting:
return False
print('hello from the monkey-patcher')
# Register the handlers...
# g.registerHandler('after-create-leo-frame', onCreate)
g.old_openUNLFile = g.openUNLFile
g.openUNLFile = new_open_unl

g.plugin_signon(__name__)
return True

-- 
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/51b678c8-da47-4568-85fe-78bedc103107n%40googlegroups.com.


LeoJS: What is the equivalent of LeoPyRef.leo?

2023-12-23 Thread Thomas Passin
IOW, where or how do we look at Leo's code? Locations like *g.app.leoDir* 
are undefined.

-- 
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/2693f50c-9361-4cd1-9244-307f83b09e08n%40googlegroups.com.


Re: question about code organization issues for personal common libraries and multiple plug-ins

2023-12-23 Thread Thomas Passin
It sounds more complex than necessary to me.  I'm not sure what kind of 
functions you have in mind.  But there are several ways to attach functions 
globally.  One way is that g has a user dict, whose name I forget right 
now.  Let's call it g.userdict, though that's probably not its real name. 
Then you can write a script the assigns

def func1():
# body of function

g.userdict['func1') = func1
# etc

Or you can just assign functions to g itself:
g.func1 = func1

For example, my mind map commands apply a monkey patch to c.  The code that 
constructs a mind map checks to see if the monkey patch has been applied 
and if not it applies it.  This look like:

# Check if we have not been run before or if the rendering 
# device has been changed
_render_dev = c.config.getString('mmap_render_dev')
if not hasattr(c, 'render_dev') or c.render_dev != _render_dev:
# Install our patch
c.executeMinibufferCommand('mmap-monkeypatch')
c.render_dev = _render_dev

c.build_mmap(data)

In the monkey patch subtree:

"""This command adds a function to the outline commander c that is
used by the top-level mind mapping commands.  This function
generates the svg output for a mindmap and renders it in
the specified rendering pane or program.  The rendering
"device" is specified by the setting "mmap_render_dev".
"""
@command mmap-monkeypatch
# ...
def build_mmap(data):
"""Parse data and build mindmap."""
data = data.replace('&', '+').replace('<', ' ')
svg = create_map(IndentedParser, data)

find_or_create_target(c, TARGET_NODE, svg)
render_with_device(svg)

# Let others know body has changed.
editor = c.frame.body.wrapper.widget
doc = editor.document()
doc.setModified(True)

c.build_mmap = build_mmap

You can put all these function definitions in a node or nodes and install 
them by running the node with CTRL-b.  Or if there are so many that you 
want to put them in a module, you can import them from the module, but it 
doesn't have to be a plugin.  You could put it into, for example, 
~/.leo/functions.  You can add that location to the Python system path, 
then import your function definition module from there.

So there are many possibilities for adding your own functions and command 
that can be stored right in subtrees in myLeoSettings.leo, or in a module, 
without even needing a plugin.  Or a plugin could use the same techniques 
to install your functions. If you want to write them as Leo minibuffer 
commands, you can create menu items for them, so that you can access them 
from Leo's menubar (you do that in myLeoSettings.leo, or in particular 
outlines).

Just look for the simplest thing that could work, and go on from there.   I 
have all the code to run my browser bookmarks system right in a subtree in 
the outline that stores the bookmarks themselves. I prototyped the code to 
highlight the current line, and  the code to draw a right margin line, in 
subtrees in the workbook.  Here's how the highlighting code gets installed 
(in the prototype;  the highlighter code that Leo actually uses was derived 
from this but is part of the core code so it doesn't need to be installed 
each time Leo is run):

class Hiliter:
def __init__(self, cc):
self.c = cc
w = cc.frame.body.wrapper
self.editor = w.widget
# .

# Install the highlighter in all commanders
for cc in g.app.commanders():
cc.hiliter = Hiliter(cc)

cc.hiliter.editor.cursorPositionChanged.connect(cc.hiliter.highlightCurrentLine)

Presto!  All outlines now have current line highlighting installed.

-- 
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/b66beba6-bfa0-4865-91ba-afb6739d6af4n%40googlegroups.com.


Re: Does LeoJS have an equivalent to the minibuffer?

2023-12-23 Thread Thomas Passin
Aha!  That was it - I didn't make sure that a leoJS panel was focused.  
Thanks.

On Saturday, December 23, 2023 at 3:15:04 PM UTC-5 Félix wrote:

> Hello Thomas and jkn :)
>
> Indeed, as stated in LeoJS *readme *at 
> https://github.com/boltex/leojs?tab=readme-ov-file#features the 
> keybindings will be effective* if your mouse focus is in one of the LeoJS 
> panels*. (Just like in LeoInteg, which also has the same minibuffer 
> feature.) If you last clicked or tabbed outside of either the LeoJS body 
> pane, or outline, the keyboard commands will be those of other VSCode 
> extensions!
>
> > As noted in the readme:
> [image: screen.png]
>
> Pressing ALT+X shows a 'minibuffer-palette' with all commands and will 
> restrict the choices as you type in its input box. (It will 'lazy-match' 
> possible commands). Once command(s) have been ran this way, the minibuffer 
> history will be the first choice in the minibuffer, you can rapidly execute 
> past commands this way) It will put @commands and @buttons on top for easy 
> access.
>
> [image: screen.png]
>
> *Please take the time to go through the (relatively short) readme to have 
> a good overview of LeoJS capabilities! *
>
> Thanks for this question Thomas because it gave me an opportunity to 
> explain this concept to other users who may be unfamiliar with the fact 
> that vscode has THOUSANDS of keyboard shortcuts that are context sensitive. 
> And the context for LeoJS commands to be active is that the focus is in one 
> of LeoJS panels. 
>
> (it also gave me the opportunity to remind people to read the readme!! 😉 )
>
> Félix 
> On Saturday, December 23, 2023 at 2:59:27 PM UTC-5 jkn wrote:
>
>> Perhaps it is just not normally visible? From 
>> https://open-vsx.org/extension/boltex/leojs :
>>
>> """
>>The Minibuffer 
>> For those 
>> familiar with Leo, the ‘minibuffer’ serves as the nerve center for command 
>> execution. Access it through Alt+X and use the complete set of Leo’s 
>> commands!
>> """
>>
>> On Saturday, December 23, 2023 at 6:15:44 PM UTC tbp1...@gmail.com wrote:
>>
>>> IOW, how can Leo commands be run if there isn't an ALT-x/minibuffer? I 
>>> don't see one.  Am I just missing it somehow?
>>
>>

-- 
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/f53b9b35-c314-4971-b420-ffc68920ef52n%40googlegroups.com.


Does LeoJS have an equivalent to the minibuffer?

2023-12-23 Thread Thomas Passin
IOW, how can Leo commands be run if there isn't an ALT-x/minibuffer? I 
don't see one.  Am I just missing it somehow?

-- 
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/7fbc5446-b7bc-4a08-8135-b7e51147dd47n%40googlegroups.com.


Re: Discuss: retire multiple body editors?

2023-12-23 Thread Thomas Passin
My first reaction was to say no, don't retire working code.  And I think 
some people use *add-editor*, even though it's fairly unworkable for me 
personally.  My second thought was to realize that there could be a change 
to a future version of Qt that makes the code stop working.  Who is going 
to want to maintain that? So now I lean towards removing it.  Is there a 
way the removal can be scheduled for a future release, and a deprecation 
warning given in the meantime?

I wonder if leoJS has the *add-editor* command working.  I imagine that it 
would not be hard to recreate Freewin in leoJS, and I think it would be 
worth doing once the plugin  mechanism is working.

On Saturday, December 23, 2023 at 8:26:41 AM UTC-5 Thomas Passin wrote:

> As a bonus Freewin can render ReStructuredText bodies.  
>
> One point to remember is that Freewin's editor is not a full-fledged Leo 
> body editor.  It only gives you key shortcuts that the underlying Qt widget 
> gives you, for example. I find that is plenty good enough for the intended 
> purpose.
>
> On Saturday, December 23, 2023 at 4:20:41 AM UTC-5 Edward K. Ream wrote:
>
>> Thomas has just posted a discussion of the freewin plugin 
>> <https://groups.google.com/g/leo-editor/c/PRW9Aoa1rVM/m/arg63qSJ> 
>> and its use for comparing nodes and taking notes. 
>>
>> As Thomas says, this plugin is more convenient and easier to use than 
>> using multiple body panes within Leo itself.
>>
>> Is it time to retire Leo's add-editor command?  Your comments please.
>>
>> 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/a14a5355-b9e2-4dae-a364-ef424a84bf5en%40googlegroups.com.


Re: Discuss: retire multiple body editors?

2023-12-23 Thread Thomas Passin
As a bonus Freewin can render ReStructuredText bodies.  

One point to remember is that Freewin's editor is not a full-fledged Leo 
body editor.  It only gives you key shortcuts that the underlying Qt widget 
gives you, for example. I find that is plenty good enough for the intended 
purpose.

On Saturday, December 23, 2023 at 4:20:41 AM UTC-5 Edward K. Ream wrote:

> Thomas has just posted a discussion of the freewin plugin 
>  and 
> its use for comparing nodes and taking notes. 
>
> As Thomas says, this plugin is more convenient and easier to use than 
> using multiple body panes within Leo itself.
>
> Is it time to retire Leo's add-editor command?  Your comments please.
>
> 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/fc1e5f62-f3bc-442b-9f46-a990f905ab7bn%40googlegroups.com.


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Thomas Passin via Python-list

On 12/22/2023 7:27 PM, Michael Torrie via Python-list wrote:

On 12/22/23 07:02, Thomas Passin via Python-list wrote:

On my Windows 10 machine, Python scripts run without a shebang line.
Perhaps Windows 11 has added the ability to use one, but then you would
need to use the actual location of your Python executable.


Yes if you associate .py or .pyw with python.exe (or pythonw.exe), then
things work as you describe.  However it's no longer recommended to do
that.

Instead---and I think this is the default now when you install
python---you should associate both .py and .pyw files with the py
launcher (py.exe) and it will examine the shebang line of the script and
determine which version of python to run. As I said this should work
regardless of the path listed in the shebang.  Note that the shebang is
meaningless to Windows itself, and Windows Explorer. It is only
meaningful to the py launcher.  So it's customary to just use a
unix-style shebang in your python scripts.  So either #!/usr/bin/python3
or #!/usr/bin/env python3 as you would in unix.

Using the py launcher as your Windows association with .py and.pyw files
you can have multiple versions of python installed and everything works
as it should, according to your shebang, just like on Unix.


I actually don't remember how to set up the association for Python 
files.  I just always type the "py" launcher anyway, as in


py -m pip instal ...

I think that the association with py.exe must only happen if you install 
to Program Files.  As I said in my previous post, Windows still sticks 
with launching Python files with Python 3.9 even though I'm three 
version beyond that.  3.9 is the only one I installed to Program Files.


In my experience one should always make sure to know what version of 
Python is being used, at least if there is more than one version 
installed on the computer.  Even on Linux using a shebang line can be 
tricky, because you are likely to get the system's version of Python, 
and that often is not what you want.  OTOH you don't want to go 
symlinking python3 to some other version of python because then the OS 
system may not work right.  So either you have to specify the Python 
version in the shebang, or just specify the right version on the command 
line.  In that case you might as well not have included the shebang line 
at all.


I may be more sensitive to this issue because I run many different Linux 
distros in VMs to check a few programs I support to make sure they can 
run on Linux as well as Windows.  What Linux, you ask?  Well, who knows 
what our users will use? So I'm always getting Python version 
mix-and-match problems.  The system will still be at Python 3.10 but I 
need Python 3.11.  The system uses Python 3.11 but we shouldn't (or 
cannot) install our dependencies so we need a parallel install.  Etc, etc.


It's just better not to make assumptions about which version of Python 
will be running. Just specify it yourself when you can, and then you can 
be sure.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Thomas Passin via Python-list

On 12/22/2023 7:19 PM, Barry wrote:




On 23 Dec 2023, at 00:15, Thomas Passin via Python-list 
 wrote:

In neither case is the shebang line used.


As i understand it, not in front of my windows box to check.
The handler for .py file extension is set to be the py.exe
It is py.exe that understands shebang lines.


Not on my system. It may depend on whether Python gets installed to 
Program Files or to %USERPROFILE%/AppData/Local/Programs/Python.  Python 
3.9 is the last verson I installed to Program Files, and that's the 
version that Windows thinks it should use to run Python files.


Run the little test program I posted.  That will tell you which version 
of Python the system wants to use.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Thomas Passin via Python-list

On 12/22/2023 9:29 AM, Sibylle Koczian via Python-list wrote:

Am 22.12.2023 um 14:13 schrieb Barry:



On 22 Dec 2023, at 12:39, Sibylle Koczian via Python-list 
 wrote:


Hello,

I always install Python on Windows in the same manner:

- Python is not on the path,
- it is installed for all users,
- the Python Launcher is installed for all users,
- the file types .py, .pyw etc. are associated with Python.

My shebang line is usually "#!/usr/bin/env python3".

This has always worked well. I could run Python scripts in a console
window entering just the script name, by double clicking in the explorer
or using WIN+r; the two last variants for GUI or for scripts with
something like "input('Leave with Enter')" at the end.

Now I've got a new computer with Windows 11 and I've installed Python
3.12.1. On my older machine it's Windows 10 and Python 3.11.5. Reading
the Python documentation it seems my shebang lines should work as before
- but they don't. The error message:

"Unable to create process using 'C:\usr\bin\env\python
"C:\Eigen\Src\launcher_versuche.py" ': Das System kann die angegebene
Datei nicht finden."

Without the "env" in the shebang line and only without it everything
works as expected - but that's contrary to the documentation, isn't it?


This suggests a typo in the shebang line. Is there a space between env 
and python?


Barry



Tried several variants with the same script:

#!/usr/bin/env python3
# That's how I wrote it for Windows 10 / Python 3.11. It works there.

#!/usr/bin/env python
#!/usr/bin/env/python

The error messages vary a little. This is a German Windows installation,
the two variants with the space produce the same German error message,
the third produces the message I've put into my first description.

The working variant on Windows 11 / Python 3.12 is "#!/usr/bin python".


There is some important context that is missing here.  Python on Windows 
does not normally install to that location.  That is not even a Windows 
path, neither by directory name nor by path separators.


In addition, Powershell and cmd.exe do not use a shebang line, at least 
through Windows 10.  Instead, they use whatever executable has been 
registered for a file extension.  This may or may not be the version you 
think.  On my system, the OS will use Python 3.9, but actually the most 
recent Python version on my system is Python 3.12. I can demonstrate the 
difference:  here is a tiny Python file with a shebang line, called 
showme.py:


#! %USERPROFILE%\AppData\Local\Programs\Python\Python312\python.exe
import sys
print(sys.executable)

Run this with the "py" launcher:
py showme.py
# prints C:\Users\tom\AppData\Local\Programs\Python\Python312\python.exe

Run it by invoking just the script's name:
showme.py
# prints C:\Program Files\Python39\python.exe

In neither case is the shebang line used.

This makes me think that maybe the Linux subsystem for Windows is being 
used here. If so, possibly the syntax for a shebang line has been 
tightened up, or there's a typo.  Either way, I would not automatically 
assume that Windows (at least through Windows 10) ever used the shebang 
line for launching these scripts.




--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Thomas Passin via Python-list

On 12/22/2023 7:36 AM, Sibylle Koczian via Python-list wrote:

Hello,

I always install Python on Windows in the same manner:

- Python is not on the path,
- it is installed for all users,
- the Python Launcher is installed for all users,
- the file types .py, .pyw etc. are associated with Python.

My shebang line is usually "#!/usr/bin/env python3".

This has always worked well. I could run Python scripts in a console
window entering just the script name, by double clicking in the explorer
or using WIN+r; the two last variants for GUI or for scripts with
something like "input('Leave with Enter')" at the end.

Now I've got a new computer with Windows 11 and I've installed Python
3.12.1. On my older machine it's Windows 10 and Python 3.11.5. Reading
the Python documentation it seems my shebang lines should work as before
- but they don't. The error message:

"Unable to create process using 'C:\usr\bin\env\python
"C:\Eigen\Src\launcher_versuche.py" ': Das System kann die angegebene
Datei nicht finden."

Without the "env" in the shebang line and only without it everything
works as expected - but that's contrary to the documentation, isn't it?


How is a path for a linux location going to work on a Windows machine? 
On Windows, when you click on a script the OS tries to find the program 
that has been registered to run that script. Python would not have been 
installed to "C:\usr\bin\env\python".


On my Windows 10 machine, Python scripts run without a shebang line. 
Perhaps Windows 11 has added the ability to use one, but then you would 
need to use the actual location of your Python executable.


If you have several Python installations, it's better to run Python 
scripts using the "py" launcher, because Windows may have the wrong idea 
about which version to use.  The "where" command on my computer shows 
Python 3.9, but I'm actually using Python 12.


--
https://mail.python.org/mailman/listinfo/python-list


leoJS Seems To Work With VSCodium

2023-12-22 Thread Thomas Passin
VSCodium is a version of VSCode that does not include Microsoft-specific 
additions like telemetry.  It's the same code base so everything *ought* to 
work the same.

I've installed VSCodium, and leoJS seems to be working the same as on 
VSCode.

-- 
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/7f4a8218-2093-447a-bc1d-4ece9278da70n%40googlegroups.com.


Re: ✨LeoJS beta 0.2.0 Released!

2023-12-21 Thread Thomas Passin

On Wednesday, December 20, 2023 at 11:13:38 PM UTC-5 Félix wrote:

Viktor,
About rst3: I've implemented all of the rst related code in LeoJS, (see 
leoRst.ts 
in the repository 
)  but 
there's a part that I could not transliterate.  Here is the magic lines 
that I cannot reproduce easily in typescript... :)

# Third-part imports...
try:
import docutils
import docutils.core
from docutils import parsers
from docutils.parsers import rst

haha! ;) There's no library in javascript that exist (that I know of)

The rst3 command can operate without using docutils.  There's a setting 
about that, *rst3-call-docutils.* I have used rst3 for many sphinx 
documents without needing to use docutils.  Sphinx itself will use it, but 
you run as an external executable outside of the rst3 command.

I'm not sure what using docutils gets you, but it seems to me that you 
could get the command working without docutils, and if someone changes the 
settings to ask for them, output a warning message about it. (I think that 
it's connected with another setting for writing intermediate files, but I'm 
not sure of that. Anyway, I don't use it.)

-- 
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/4b3f2186-b738-4262-8c9b-98500726ac3fn%40googlegroups.com.


Re: Leo, @auto-md, and Markdeep

2023-12-19 Thread Thomas Passin

On Tuesday, December 19, 2023 at 7:38:30 PM UTC-5 off...@riseup.net wrote:

...  What has been pretty useful is also to have a web preview of the 
document running in localhost. Something similar, implemented with some 
minimal server, like Flask in Python's case or the equivalent for VS 
Code/Codium could be pretty helpful for authors using Markdeep from Leo and 
wanting and agile preview of their documents.

The *ablog* system uses Sphinx (RestructuredText) to produce blogs, and it 
can launch a localhost server to serve web views of its blog site(s).  It's 
pretty easy, one way or another,  to get a simple static server to serve 
pages.  Of course, with Leo we have the rst3 command, which makes writing 
these Sphinx documents much easier.  Presumably the same general design 
could be used for a Markdeep command or plugin.

-- 
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/01034ecf-1795-46d4-998e-4d3291314928n%40googlegroups.com.


Re: Félix Malboeuf is my GitHub successor

2023-12-19 Thread Thomas Passin
I'll echo the thanks.  It's something I've been concerned about, the 
transition whenever that time comes.

On Tuesday, December 19, 2023 at 4:51:39 AM UTC-5 Edward K. Ream wrote:

> Félix Malboeuf has accepted the responsibility of being my GitHub 
> successor 
> 
> .
>
> He will manage all my GitHub repositories (including Leo) after I am gone.
>
> Félix is the clear choice for this role:
>
> - He understands every line of Leo's core, in many cases better than I do.
> - He has superb engineering skills and judgment.
> - He has transliterated Leo into Typescript to create LeoJS, the future of 
> Leo.
>
> Many thanks to Félix for undertaking this role.
>
> 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/ac009031-df21-4392-bbde-e9749b106b9bn%40googlegroups.com.


Re: Work on Leo will be slowing

2023-12-18 Thread Thomas Passin

On Monday, December 18, 2023 at 8:19:20 AM UTC-5 Edward K. Ream wrote:

I'll continue to maintain Leo, but I am about to spend most of my 
programming time *using* Leo rather than *improving* Leo. 


I'm glad to read this.  After all, it's what Leo is *for*, to be used.  At 
this point, I'm inclined to think that any improvements to Leo should come 
from a desire to do something, the lack of which one discovers through 
using it.

-- 
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/42f23d43-5fce-487b-a89d-04b8f5889119n%40googlegroups.com.


Re: Type hints - am I doing it right?

2023-12-13 Thread Thomas Passin via Python-list

On 12/13/2023 11:17 AM, Mats Wichmann via Python-list wrote:

On 12/13/23 00:19, Frank Millman via Python-list wrote:

I have to add 'import configparser' at the top of each of these 
modules in order to type hint the method.


This seems verbose. If it is the correct way of doing it I can live 
with it, but I wondered if there was an easier way.


Think of import as meaning "make this available in my current (module) 
namespace".


The actual import machinery only runs the first time, that is, if it's 
not already present in the sys.modules dict.


There's also the approach of importing the typing objects conditionally, 
as in this snippet from the Leo Editor 
(https://github.com/leo-editor/leo-editor)


if TYPE_CHECKING:  # pragma: no cover
from leo.core.leoCommands import Commands as Cmdr
from leo.core.leoGui import LeoKeyEvent as Event

Yes, it's more verbose but it makes clear what the intent is.
--
https://mail.python.org/mailman/listinfo/python-list


Re: IDLE editor suggestion.

2023-12-12 Thread Thomas Passin via Python-list

On 2023-12-12 08:22, Steve GS via Python-list wrote:
> Maybe this already exists but
> I have never seen it in any
> editor that I have used.
>
> It would be nice to have a
> pull-down text box that lists
> all of the searches I have
> used during this session. It
> would make editing a lot
> easier if I could select the
> previous searches rather than
> having to enter it every time.
>
> If this is inappropriate to
> post this here, please tell me
> where to go.
> Life should be so
> complicated.
>
EditPad has this.

So do Notepad++, EditPlus (not free but low cost, Windows only, and very 
good), and I'm sure many others that are much simpler than Visual Studio 
Code, for example.

--
https://mail.python.org/mailman/listinfo/python-list


Re: ✨LeoJS beta 0.2.0 Released!

2023-12-10 Thread Thomas Passin

On Sunday, December 10, 2023 at 10:53:00 PM UTC-5 Félix wrote:

For the web version, you have to have at least a repo created with at least 
one commit. Creating a new repo and also adding an automatic readme file 
inside of it while you create it do work if I recall correctly.
(Totally new and empty repos will not work, as github only really creates a 
repo after the first commit.) 


My problem was that I couldn't even get it to find a GitHub repo I know 
exists (like leo-editor, or any of my own), and I couldn't work out how to 
get it to authenticate with GitHub.  I imagine you cannot make this problem 
occur because it takes a new user that has never gone through the leoJS 
install process before.  As a known user, you can't get this to happen.

Your innocence is touching but hard to debug :-) .

-- 
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/4e1d6557-bbfd-4a4d-a81a-980912cfd418n%40googlegroups.com.


Re: ✨LeoJS beta 0.2.0 Released!

2023-12-10 Thread Thomas Passin
All right, it installed in vsc and it did open an outline.  I saw a lot of 
errors like this:

reading settings in C:/Users/tom/.leo/workbook.leo
TypeError: Cannot read properties of undefined (reading 'trim')
at Ini_Importer.find_blocks 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1507413)
at Ini_Importer.gen_block 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1508153)
at Ini_Importer.gen_lines 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1511889)
at Ini_Importer.import_from_string 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1512400)
at exports.do_import 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1522910)
at LeoImportCommands.createOutline 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1338218)
at async AtFile.readOneAtAutoNode 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:955878)
at async AtFile.readFileAtPosition 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:954544)
at async AtFile.readAll 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:953359)
at async FileCommands.readExternalFiles 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1151896)
at async FileCommands._getLeoFileByName 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1151493)
at async FileCommands.getAnyLeoFileByName 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1149953)
at async LoadManager.openFileByName 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:937514)
at async LoadManager.loadLocalFile 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:936309)
at async SessionManager.load_session 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1439599)
at async LoadManager.doPostPluginsInit 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:932259)
at async LoadManager.load 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:931126)
at async runLeo 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1807739)
at async activate 
(c:\Users\tom\.vscode\extensions\boltex.leojs-0.2.0\dist\extension-node.js:2:1815070)
at async u.n (c:\Users\tom\AppData\Local\Programs\Microsoft VS 
Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6255)
at async u.m (c:\Users\tom\AppData\Local\Programs\Microsoft VS 
Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6218)
at async u.l (c:\Users\tom\AppData\Local\Programs\Microsoft VS 
Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:5675)

On Sunday, December 10, 2023 at 10:06:13 PM UTC-5 Thomas Passin wrote:

> I'm afraid I can't get started.  The beta insists on opening a repo first, 
> but I can't figure out how to either find my own repos or to get 
> authenticated for Github.
>
> I'd rather start working on a .leo file that isn't in a repo at all.  I'm 
> never going to have all my outlines in a repo, but I want to be able to 
> open them anyway.  My personal, on-computer repo is Mercurial anyway, not 
> git, and I don't feel like trying to change everything in Mercurial over to 
> git.  So I hope that leoJs can be convinced to work with mercurial if it's 
> not going to be able to work with individual outlines on my drive.
>
> I'll try with vscode next.
>
> On Sunday, December 10, 2023 at 8:43:15 PM UTC-5 Félix wrote:
>
>> [image: leojs banner1.png]
>> 🚀*LeoJS Debuts!*🌟
>>
>> I'm thrilled to unveil LeoJS 'beta' 0.2.0 
>> <https://marketplace.visualstudio.com/items?itemName=boltex.leojs>, a 
>> JavaScript implementation of the Leo Editor, now reimagined as a VSCode 
>> extension. Building on the foundation of LeoInteg, LeoJS revolutionizes 
>> your coding environment by seamlessly integrating into VSCode.
>>
>> Available on the VSCode marketplace 
>> <https://marketplace.visualstudio.com/items?itemName=boltex.leojs>, or, 
>> for VSCodium <https://github.com/VSCodium/vscodium>, on the open-vsx 
>> marketplace <https://open-vsx.org/extension/boltex/leojs>.
>>
>> *Key Features of LeoJS*
>>
>>  - Like its predecessor, LeoInteg, LeoJS employs VSCode's robust GUI to 
>> host a variety of panels and controls, offering a smooth and familiar user 
>> experience.
>>
>>  -   With its entire architecture in TypeScript, LeoJS operates directly 
>> within VSCode — no external servers or additional communication layers. 
>> This direct integ

Re: ✨LeoJS beta 0.2.0 Released!

2023-12-10 Thread Thomas Passin
I'm afraid I can't get started.  The beta insists on opening a repo first, 
but I can't figure out how to either find my own repos or to get 
authenticated for Github.

I'd rather start working on a .leo file that isn't in a repo at all.  I'm 
never going to have all my outlines in a repo, but I want to be able to 
open them anyway.  My personal, on-computer repo is Mercurial anyway, not 
git, and I don't feel like trying to change everything in Mercurial over to 
git.  So I hope that leoJs can be convinced to work with mercurial if it's 
not going to be able to work with individual outlines on my drive.

I'll try with vscode next.

On Sunday, December 10, 2023 at 8:43:15 PM UTC-5 Félix wrote:

> [image: leojs banner1.png]
> 🚀*LeoJS Debuts!*🌟
>
> I'm thrilled to unveil LeoJS 'beta' 0.2.0 
> , a 
> JavaScript implementation of the Leo Editor, now reimagined as a VSCode 
> extension. Building on the foundation of LeoInteg, LeoJS revolutionizes 
> your coding environment by seamlessly integrating into VSCode.
>
> Available on the VSCode marketplace 
> , or, 
> for VSCodium , on the open-vsx 
> marketplace .
>
> *Key Features of LeoJS*
>
>  - Like its predecessor, LeoInteg, LeoJS employs VSCode's robust GUI to 
> host a variety of panels and controls, offering a smooth and familiar user 
> experience.
>
>  -   With its entire architecture in TypeScript, LeoJS operates directly 
> within VSCode — no external servers or additional communication layers. 
> This direct integration ensures faster responses and a more efficient 
> workflow.
>
>  -   LeoJS introduces live JavaScript script execution, providing a 
> dynamic and flexible scripting environment. This feature extends the 
> versatility of Leo beyond its traditional Python-based framework.
>
>  -   The bulk of Leo's core and command classes have been meticulously 
> ported to TypeScript in LeoJS.
>
>  -   Key plugins from Leo, such as quicksearch.py, nodeTags.py, and 
> mod_scripting.py, are seamlessly integrated into LeoJS's core.
>
> *Web Compatibility*
>
> LeoJS isn't just for desktops. For the first time ever, run Leo as a web 
> extension on vscode.dev, enabling direct editing of Leo documents in 
> online repositories. 
>
> ( See 
> https://code.visualstudio.com/docs/editor/vscode-web#_opening-a-project )
>
> Simply visit a GitHub repository, press '.' to switch to the VSCode web 
> edition, install LeoJS from the extension panel, and you're set!
>
> For local document editing, the regular desktop version of LeoJS & VSCode 
> remains your go-to option.
>
> *Using LeoJS alongside LeoInteg*
>
> For those who use both extensions, you'll notice distinct activity bar 
> icons and panels for each. To avoid clutter in the explorer panel, LeoInteg 
> will automatically hide when LeoJS's 'show-in-explorer' setting is enabled.
>
> *Join the Beta Release Journey*
>
> I invite you to be part of this exciting phase: Your feedback and bug 
> reports  are invaluable in 
> refining LeoJS for a full release!
>
> Many thanks to Edward for creating Leo, and thanks to you, for trying it 
> out and helping squash the remaining bugs! 😆
>
> Félix
>

-- 
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/c13ae9a1-002a-4a7b-8436-b9c135b365cen%40googlegroups.com.


Re: recommend an approach or path to learning more about Leo

2023-12-10 Thread Thomas Passin

On Sunday, December 10, 2023 at 9:08:27 AM UTC-5 Thomas Passin wrote:

On Sunday, December 10, 2023 at 8:23:53 AM UTC-5 Edward K. Ream wrote:

To see these in action, run a test program in *another* console.


...

You don't need to do this for a script that doesn't change code that Leo 
uses, but otherwise test in a second session.  You will have to close it 
each time you make a correction, but you will keep your place in the code 
in the original window, which would probably open more slowly as well.


Another big benefit of using a second Leo session is if you are working on 
core Leo code and you make a mistake that prevents Leo from running.  If 
you only used the one Leo window, you are in trouble because you won't be 
able to start Leo to fix the mistake.  If the second session fails you can 
fix up the problem in the still-open first session.

Don't scoff, it's happened to me many times.

-- 
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/662981ae-41f7-4b04-b75b-f989a4521214n%40googlegroups.com.


Re: recommend an approach or path to learning more about Leo

2023-12-10 Thread Thomas Passin

On Sunday, December 10, 2023 at 9:26:06 AM UTC-5 iamap...@gmail.com wrote:

On Sunday, December 10, 2023 at 8:23:53 AM UTC-5 Edward K. Ream wrote:

To see these in action, run a test program in *another* console.


This little tip is remarkably useful. Whether you are working on Leo code 
or your own, each time you want to test a change run a new copy of Leo and 
keep the original Leo session open.  You can designate a particular outline 
(often the workbook, the way I work) on the command line so the second Leo 
session will open faster. 

You don't need to do this for a script that doesn't change code that Leo 
uses, but otherwise test in a second session.  You will have to close it 
each time you make a correction, but you will keep your place in the code 
in the original window, which would probably open more slowly as well.

Thank you Thomas, your explanation is very, very clear. I get the point. 


I forgot to say that I run the second Leo session using a theme with a 
different color scheme from the first one.  That way I don't get mixed up 
and make a change in or close the wrong window.  You can set a specific 
theme with the --theme= command line parameter.

-- 
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/ed458b79-25af-4e49-ba68-447f166ce4a9n%40googlegroups.com.


Re: recommend an approach or path to learning more about Leo

2023-12-10 Thread Thomas Passin

On Sunday, December 10, 2023 at 8:23:53 AM UTC-5 Edward K. Ream wrote:

To see these in action, run a test program in *another* console.


This little tip is remarkably useful. Whether you are working on Leo code 
or your own, each time you want to test a change run a new copy of Leo and 
keep the original Leo session open.  You can designate a particular outline 
(often the workbook, the way I work) on the command line so the second Leo 
session will open faster. 

You don't need to do this for a script that doesn't change code that Leo 
uses, but otherwise test in a second session.  You will have to close it 
each time you make a correction, but you will keep your place in the code 
in the original window, which would probably open more slowly as well.

-- 
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/26d004cb-69a8-45d3-88f9-1c25130d6d9bn%40googlegroups.com.


Re: A problem with str VS int.

2023-12-09 Thread Thomas Passin via Python-list

On 12/9/2023 9:42 PM, Steve GS via Python-list wrote:

  If I enter a one-digit input or a three-digit number, the code works but if I 
enter a two digit number, the if statement fails and the else condition 
prevails.

tsReading = input("   Enter the " + Brand + " test strip reading: ")
 if tsReading == "": tsReading = "0"
 print(tsReading)
 if ((tsReading < "400") and (tsReading >= "0")):
 tsDose = GetDose(sReading)
 print(tsReading + "-" + tsDose)
 ValueFailed = False
 else:
 print("Enter valid sensor test strip Reading.")

I converted the variable to int along with the if statement comparison and it 
works as expected.
See if it fails for you...


I don't have to try it to know it will fail.  You think you are 
comparing numbers but you are comparing strings instead, which won't 
work as you expect.


You would do better to convert the inputs and limits to numbers, as well 
as the GetDose() function.  In a more realistic version, you would also 
have to make sure the user input is legal, either an int or a float, 
whichever you want to work with.


And along those lines (a more realistic version), it would be preferable 
to change the limits to be named constants, which will make the code 
easier to understand and change when it's revisited later.  Something 
like this:


UPPER = 400
LOWER = 0
# ...
if LOWER < value < UPPER:
# .

--
https://mail.python.org/mailman/listinfo/python-list


Re: Fix For Ctrl-Click On UNL Not Opening Outline

2023-12-09 Thread Thomas Passin

On Saturday, December 9, 2023 at 11:57:09 PM UTC-5 lewis wrote:

I set myLeoSettings file to:
@string unl-status-kind = legacy

I then created a *new* leo file and created a new node: Test UNLs for 
Thomas - legacy 

You are correct the new version UNLs don't have the full path to the file:
unl://Test_UNLs.leo#Test UNLs for Thomas - legacy

Ctrl-click on a node with that new version UNL does not open the file. Nor 
does it move to file if already open


Exactly.  My patch fixes the problems in so far as it can given that the 
UNLs don't include the absolute path any more. The heuristic it uses is

Look for locations in the following places in order:
1. The currently selected outline
2. All open outlines
3. Files specified in an @data setting named 'unl-path-prefixes'
4. Certain well-known files like PyLeoRef.leo
5. The outlines listed in the Recent Files menu.
 
#3 is a new setting that Edward introduced when he made the recent changes 
to the UNL machinery.  I think (or maybe just hope) that #5 will catch most 
cases of interest, but it's not a perfect solution.

-- 
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/2c88e362-e8c8-4ab3-86b7-73f66c20a242n%40googlegroups.com.


Re: Fix For Ctrl-Click On UNL Not Opening Outline

2023-12-09 Thread Thomas Passin
What version or changeset are you running?  It's been broken for me in 
devel for a while, and also in 6.7.5.  I get UNLs from nodes, and they look 
like this:

unl:gnx://LeoPyRef.leo#ekr.20230630132340.1  (New style)
unl://workbook.leo#get unl body ("Legacy" style)

Neither form works for me with a CTRL-click for a file outside the current 
outline, because -

The new version UNLs do not include the full path to a file, whereas your 
example does.  Without the full path, the navigation method has to try a 
series of heuristics to work out the path, and that's what the current 
method doesn't get right. I get the UNLs to test using p.get_UNL() or 
p.get_legacy_UNL().  If your example UNL string came from an older version 
of Leo, well, that's not what you would get with current versions.
On Saturday, December 9, 2023 at 9:33:13 PM UTC-5 lewis wrote:

> Ctrl-click on UNL is not broken for me :)
>

-- 
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/45566292-0523-4dfa-b517-6094a52a7bb2n%40googlegroups.com.


Fix For Ctrl-Click On UNL Not Opening Outline

2023-12-09 Thread Thomas Passin
Ctrl-clicking on a UNL string in a node is supposed to navigate to that 
location, even if it's in another outline.  That outline should open if 
it's not already.  But after the recent changes to the UNL design, the 
functionality only works within the same outline.  It won't open an outline 
and navigate to the target node.

A fix is in the works, but Edward and Felix don't have a lot of extra 
cycles right now to review and approve the PR.  So here is a monkey-patch 
that restores the navigation capability in advance of merging the PR.  This 
is basically the same code as is in the PR, packaged as a little outline 
that can do the monkey-patching.  The code changes g.openUNLFile().

To use, open the outline, select its top-level node, and run its script 
(with CTRL-b).  The patch will need to be applied again each time you start 
Leo.

-- 
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/e9f6f810-a0c2-40eb-b406-9f7691af0f15n%40googlegroups.com.


https://leo-editor.github.io/leo-editor/namespaces/leo-python-editor/1.1"; >





openUNLFile Monkey-patch
<< well-known outlines >>



import os
def openUNLFile(c, s):
"""
Open the commander for filename s, the file part of an unl.

Return None if the file can not be found.

Look for locations in the following places in order:
1. The currently selected outline
2. All open outlines
3. Files specified in an @data setting named 'unl-path-prefixes'
4. Certain well-known files like PyLeoRef.leo
5. The outlines listed in the Recent Files menu.
"""
base = os.path.basename
norm = os.path.normpath
c_name = c.fileName()
path = ''

def standard(path: str) -> str:
"""Standardize the path for easy comparison."""
return norm(path).lower()

if not s.strip():
return None
if s.startswith('//') and s.endswith('#'):
s = s[2:-1]
if not s.strip():
return None
# Always match within the present file.
if os.path.isabs(s) and standard(s) == standard(c_name):
return c
if not os.path.isabs(s) and standard(s) == standard(base(c_name)):
return c
if os.path.isabs(s):
path = standard(s)
else:
# Check for outlines defined in 'unl-path-prefixes' settings
# Values of d should be directories.
d = g.parsePathData(c)
path = base_s = base(s)
directory = d.get(base_s)
if directory and os.path.exists(directory):
path = standard(os.path.join(directory, base_s))
if path == standard(c_name):
return c
# Search all open commanders.
# This is a good shortcut, and it helps unit tests.
# "path" is always going to be a filename without directories
for c2 in g.app.commanders():
if path.lower() == base(standard(c2.fileName())):
return c2
# Check well-known files and recent files list
<< well-known outlines >>
all = well_known + g.app.recentFilesManager.getRecentFiles()
for f in all:
if path.lower() == base(standard(f)):
if os.path.exists(f):
return g.openWithFileName(f)
break  # In Recent Files but no longer exists
return None

g.openUNLFile = openUNLFile
ld = g.app.loadDir
well_known = [
f'{ld}/LeoPyRef.leo',
f'{ld}/../doc/CheatSheet.leo',
f'{ld}/../doc/LeoDocs.leo',
f'{ld}/../doc/leoSlideShows.leo',
f'{ld}/../scripts/scripts.leo',
]





Re: recommend an approach or path to learning more about Leo

2023-12-09 Thread Thomas Passin
Leo programming can definitely be a challenge.  It's tempting to say "go 
look at plugin X", for example, but what's really needed is a way to find 
out how to do things, how to discover the right existing part of Leo's code 
base, and how to go about the work effectively.  There isn't anything 
comprehensive along these lines, and Leo is so big and capable that it can 
support a great number of very different kinds of scripts an applications.  
LeoDocs and the Cheat Sheet help, but only scratch the surface.

In addition, in many cases one has to learn some PyQt as well, and that has 
its own learning curve.  I tend to learn about using Qt by writing small 
scripts to some some Qt thing I'm interested in.

I've been slowly working a New User's Guide, but it won't cover the kinds 
of things you are asking about even when I get it more fully fleshed out.

Since you mentioned writing a interface for the log pane, here's a link to 
a series of posts I wrote about creating applications that run in a tab: 
Creating 
Qt Apps That Run In A Tab 


I think that the suggestion of writing plugins is good, but I find it even 
easier to write experimental code as scripts in a Leo outline.  With a 
script it's easy to experiment, and you can even write code that changes 
core Leo behavior.  For example, Leo can optionally show a vertical guide 
line at the right margin of the body.  I developed that code in a script.  
The script monkey-patched core Leo code.  When I got it working right, I 
then went ahead and incorporated the code (via a pull request) into Leo's 
code base in PyLeoRef.  Remember, you can use the full power of @others and 
named sections in a Leo script, and you don't even have to have the script 
in an external file.

There are various little techniques that make working with Leo's code 
easier.  Different people use different ones and I don't think there's an 
extensive compilation anywhere.  I make heavy use of searching with the Nav 
tab, and marking nodes for easy navigation.  Edward makes effective use of 
clones and search patterns.

This may not have been all that helpful, but I think that working out ways 
to find Leo's features and interfacing with them is one of the more 
important things you can do, and that's going to take a lot of trial and 
error.  Taking on a limited task as you did with a log pane interface is 
definitely a good way to start.

On Saturday, December 9, 2023 at 10:07:25 AM UTC-5 iamap...@gmail.com wrote:

> Hi, Jake,
>
> Thanks for your idea. 
>
> I do like learning deeply, but step by step.
> I mean, I don't want learning curve 'too steep'
>
> [image: image.png]
>
>
>
> On Sat, Dec 9, 2023 at 10:14 PM Jacob Peck  wrote:
>
>> "Too deep" is definitely a bit subjective, and will vary by person.
>>
>> But what I found helpful is to build a few plugins.  Find some pocket of 
>> your workflow that you think could be just a little bit better 'if ' 
>> and write a plugin that does .
>>
>> Plugins are a good way, imo, to limit your exposure -- you'll likely only 
>> be interacting with the parts of Leo's code you really need for your 
>> intended functionality.  Unfortunately there's no real way to avoid reading 
>> Leo's source code, but you definitely don't have to drink from the firehose 
>> to get a better understanding of it.
>>
>> Jake
>>
>> On Sat, Dec 9, 2023 at 9:02 AM HaveF HaveF  wrote:
>>
>>> Hello,
>>>
>>> I have mastered the basics of Leo and am using it daily this year. I can 
>>> use Leo to manage contents, write commands, create buttons, and even 
>>> develop a small interface on the Log/Find/Tags/Nav panel. However, I'm not 
>>> satisfied and wish to delve deeper into Leo. 
>>>
>>> I have an idea to create an importer for a specific file format, but I 
>>> stopped by my understanding of Leo.
>>> Create an importer is not important and not a high priority for me, It's 
>>> just one of many ideas that I can't implement because I don't know Leo well 
>>> enough.
>>>
>>> I'm eager to expand my knowledge of Leo. While reading code is a viable 
>>> learning method, I find the scope of Leo overwhelming. Could you recommend 
>>> an approach or path to learning more about Leo that is *manageable and 
>>> not too steep*?
>>>
>>> Thanks!
>>>
>>> -- 
>>> 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+...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/leo-editor/bd6bd906-bfe5-4425-a68b-cad2dd6e4783n%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>> -- 
>>
> You received this message because you are subscribed to a topic in the 
>> Google Groups "leo-editor" group.

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Thomas Passin via Python-list

On 12/6/2023 1:12 PM, MRAB via Python-list wrote:

On 2023-12-06 12:23, Thomas Passin via Python-list wrote:

On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote:



On 6 Dec 2023, at 09:32, Chris Green via Python-list 
 wrote:


My requirement is *slightly* more complex than just key value pairs,
it has one level of hierarchy, e.g.:-

    KEY1:
  a: v1
  c: v3
  d: v4
    KEY2:
  a: v7
  b: v5
  d: v6

Different numbers of value pairs under each KEY.


JSON will allow you to nest dictionaries.

{
 'KEY1': {
 'a': v1
 'c': v3
 'd': v4
 }
 'KEY2': {
  'a': v7
  'b': v5
  'd': v6
 }
}

Personally I would not use .ini style these days as the format does 
not include type of the data.


Neither does JSON.  Besides, JSON is more complicated than necessary
here - in fact, your example isn't even legal JSON since lines are
missing commas.

Fun fact - for at least some, maybe most, JSON files, using eval() on
them is hugely faster than using Python's standard JSON library.  I
learned this when I wanted to ingest a large browser bookmarks JSON
file. It wouldn't matter for a much smaller file, of course.


It would be safer if you used literal_eval.


He's going to be writing his own calibration data files, though, so it 
should be safe for his purposes.


--
https://mail.python.org/mailman/listinfo/python-list


Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Thomas Passin via Python-list

On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote:




On 6 Dec 2023, at 09:32, Chris Green via Python-list  
wrote:

My requirement is *slightly* more complex than just key value pairs,
it has one level of hierarchy, e.g.:-

KEY1:
  a: v1
  c: v3
  d: v4
KEY2:
  a: v7
  b: v5
  d: v6

Different numbers of value pairs under each KEY.


JSON will allow you to nest dictionaries.

{
 'KEY1': {
 'a': v1
 'c': v3
 'd': v4
 }
 'KEY2': {
  'a': v7
  'b': v5
  'd': v6
 }
}

Personally I would not use .ini style these days as the format does not include 
type of the data.


Neither does JSON.  Besides, JSON is more complicated than necessary 
here - in fact, your example isn't even legal JSON since lines are 
missing commas.


Fun fact - for at least some, maybe most, JSON files, using eval() on 
them is hugely faster than using Python's standard JSON library.  I 
learned this when I wanted to ingest a large browser bookmarks JSON 
file. It wouldn't matter for a much smaller file, of course.


--
https://mail.python.org/mailman/listinfo/python-list


Re: How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread Thomas Passin via Python-list

On 12/5/2023 11:50 AM, MRAB via Python-list wrote:

On 2023-12-05 14:37, Chris Green via Python-list wrote:

Is there a neat, pythonic way to store values which are 'sometimes'
changed?

My particular case at the moment is calibration values for ADC inputs
which are set by running a calibration program and used by lots of
programs which display the values or do calculations with them.

 From the program readability point of view it would be good to have a
Python module with the values in it but using a Python program to
write/update a Python module sounds a bit odd somehow.

I could simply write the values to a file (or a database) and I
suspect that this may be the best answer but it does make retrieving
the values different from getting all other (nearly) constant values.

Are there any Python modules aimed specifically at this sort of
requirement?

Some kind of key/value store sounds like the correct solution. I 
wouldn't go as far a database - that's overkill for a few calibration 
values.


I might suggest TOML, except that Python's tomllib (Python 3.11+) is 
read-only!


Personally, I'd go for lines of:

     key1: value1
     key2: value2

Simple to read, simple to write.


Just go with an .ini file. Simple, well-supported by the standard 
library. And it gives you key/value pairs.


--
https://mail.python.org/mailman/listinfo/python-list


Re: mod_http plugin issue

2023-11-28 Thread Thomas Passin
It uses an obsolete module.  As of Python 3.12, from the Python docs for 
asynchat:

"Deprecated since version 3.6, will be removed in version 3.12: The asynchat 
 module 
is deprecated (see *PEP 594*  for 
details),  Please use asyncio 
 instead."

Using Python 3.12 on my system, it was unable to start and I didn't see any 
error messages.  Looks like someone is going to have to revise the code.

On Tuesday, November 28, 2023 at 2:56:27 PM UTC-5 lewis wrote:

> I have the mod_http.py plugin enabled in myLeoSettings.leo however when 
> Leo starts the log pane does not show the message 'http serving enabled at 
> 127.0.0.1:8130'
>
> http://localhost:8130/ in a browser is unable to connect and can’t 
> establish a connection to the server at localhost:8130.
> I'mrunning Leo 6.7.6-devel, devel branch, build 1ca1bbfaa4.
> Can anyone confirm the plugin works?
>

-- 
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/6327edc7-db60-4d17-b14a-bd5149408f72n%40googlegroups.com.


Re: jupyter notebook use issue

2023-11-27 Thread Thomas Passin
It occurs to me that it should be fairly easy to create a Leo plugin that 
would display an .ipynb file.  Both VR and VR3 used to do this.  They used 
a pip-installable module that converted it to HTML and displayed that, 
IIRC.  We could resurrect that code into the new plugin.  The plugin would 
let you view the .ipynb file in another pane while you had its Jupytext 
paired file open as a regular Python file in Leo.  I'd probably want to add 
a new directive to specify the paired file.

If this works out, it could be a really nice addition to Leo, at least for 
Jupyter files that use only Python.

On Monday, November 27, 2023 at 8:00:34 AM UTC-5 Thomas Passin wrote:

> Very sweet, and ideally suited to work with Leo.  
>
> On Monday, November 27, 2023 at 2:52:53 AM UTC-5 iamap...@gmail.com wrote:
>
>> Ok, it seems jupytext is the right choice. It can pair notebook with 
>> python file. I just use Leo to handle the python files :-D Great!
>>
>> https://github.com/mwouts/jupytext#paired-notebooks
>>
>>
>> On Monday, November 27, 2023 at 11:21:52 AM UTC+8 HaveF HaveF wrote:
>>
>>> There used to be some support for Jupyter notebooks, but over time it 
>>>> became clear that it didn't work well.  You could read them but not 
>>>> interact or modify them effectively.  Since you can read them better in a 
>>>> browser, the support was removed.
>>>>
>>>  
>>> I see, Thomas. Reading the notebook is fine. But it lacks the clone 
>>> function of leo. Since there is always some code that is generic for 
>>> some typical analysis (but I don't have it abstracted into functions), I 
>>> wondered if I could use Leo's clone feature to extract out the code 
>>> separately so that the content of the code paragraphs could be synchronized 
>>> after each change. At the moment, it seems that there is no way to solve 
>>> this problem, and perhaps the practical way is to abstract this content 
>>> into functions to manage it.
>>>
>>>

-- 
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/73854119-d9e7-44a3-af0e-416215962fc1n%40googlegroups.com.


Re: jupyter notebook use issue

2023-11-27 Thread Thomas Passin
Very sweet, and ideally suited to work with Leo.  

On Monday, November 27, 2023 at 2:52:53 AM UTC-5 iamap...@gmail.com wrote:

> Ok, it seems jupytext is the right choice. It can pair notebook with 
> python file. I just use Leo to handle the python files :-D Great!
>
> https://github.com/mwouts/jupytext#paired-notebooks
>
>
> On Monday, November 27, 2023 at 11:21:52 AM UTC+8 HaveF HaveF wrote:
>
>> There used to be some support for Jupyter notebooks, but over time it 
>>> became clear that it didn't work well.  You could read them but not 
>>> interact or modify them effectively.  Since you can read them better in a 
>>> browser, the support was removed.
>>>
>>  
>> I see, Thomas. Reading the notebook is fine. But it lacks the clone 
>> function of leo. Since there is always some code that is generic for 
>> some typical analysis (but I don't have it abstracted into functions), I 
>> wondered if I could use Leo's clone feature to extract out the code 
>> separately so that the content of the code paragraphs could be synchronized 
>> after each change. At the moment, it seems that there is no way to solve 
>> this problem, and perhaps the practical way is to abstract this content 
>> into functions to manage it.
>>
>>

-- 
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/4fc55ec3-88bb-4b2f-821a-4c84ce3fd5e4n%40googlegroups.com.


Re: jupyter notebook use issue

2023-11-26 Thread Thomas Passin
There used to be some support for Jupyter notebooks, but over time it 
became clear that it didn't work well.  You could read them but not 
interact or modify them effectively.  Since you can read them better in a 
browser, the support was removed.

On Sunday, November 26, 2023 at 9:54:44 PM UTC-5 Edward K. Ream wrote:

> On Sun, Nov 26, 2023 at 8:49 PM HaveF HaveF wrote:
>
>> You might try using leoInteg in vscode. vscode probably has pretty good 
>>> support for Jupyter notebooks.
>>>
>>  
>> Thanks for your advice, Edward
>>
>
> You're welcome. Please let us know how you fare.
>
> 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/ab2fa7b9-080c-41bf-86a4-c13d0e603e4en%40googlegroups.com.


Re: Leo, @auto-md, and Markdeep

2023-11-26 Thread Thomas Passin
I tried to reply twice - innocuously - but the system deleted my posts 
immediately.  That hasn't happened on other threads.  Anyone understand why?

On Saturday, November 25, 2023 at 9:49:55 PM UTC-5 Edward K. Ream wrote:

> On Tuesday, November 21, 2023 at 1:19:17 PM UTC-6 UrbanUnPlanner wrote:
>
> I am looking to use Leo to help me organize an upcoming writing project, 
> and also found (through this group, even) the Markdeep (
> https://casual-effects.com/markdeep/) authoring format and went "hey, 
> this looks suitable for my purposes."  Furthermore, that brought me to 
> Leo's @auto support for Markdown, which made me think "great! I can use 
> that to let me collaborate with people who are using other tools".
>
> However, in order to achieve its polyglot capabilities (both editable as 
> Markdown-style text _and_ viewable in a browser without any offline build 
> steps), Markdeep relies on a trailer line of HTML.  To my chagrin, however, 
> Leo's @auto functionality is not compatible with the normal @last mechanism 
> for placing trailer lines into output files.
>
> So, what should I do to get that trailer line to reliably output at the 
> end of the @auto generated file, especially if I want to use a clone node 
> to provide a single source of trailer truth across multiple @auto files and 
> want to be able to roundtrip manual edits back into Leo?
>
>
> Interesting question. Have you tried using @clean?
>
> 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/90277ad7-6345-4076-8457-2b5dc30597e8n%40googlegroups.com.


Re: Discuss: Always write Black-compatible sentinels

2023-11-25 Thread Thomas Passin
My main reaction is to make sure that Leo's read behavior remains backwards 
compatible with the pre-black sentinel format. People with much older 
outlines should be able to open them for the indefinite future.  It's also 
possible that there is some user code that does something with sentinels 
and assumes there will be no space after the leading '#' character.  So 
perhaps the  *--black-sentinels** command line option* should remain in 
reverse:  *--black-sentinels**=False * would be allowed but not be the 
default .

With this proviso, the proposal seems sensible.

On Saturday, November 25, 2023 at 4:52:05 PM UTC-5 Edward K. Ream wrote:

> Issue #3657  suggests 
> that Leo should *always *write black-compatible sentinel lines. Leo would 
> no longer need the *--black-sentinels* command line option.
>
>
> This post discusses this proposal and asks for your comments.
>
>
> *Background*
>
>
> Black  adds a space between the # and @ 
> at the start of Leo's sentinel comments, treating such comments according 
> to the PEP8  guidelines for inline 
> comments .
>
>
> As a result, *Black will continually reformat Leo's external files* unless 
> the --black-sentinels command line option was in effect when Leo wrote the 
> external files.
>
>
> The Black devs do not appear interested in treating Leo's sentinels as 
> exceptions!
>
>
> *Compatibility*
>
>
> For at least the last several years, Leo has been able to read external 
> files containing "blackened" comments. I know of no significant 
> compatibility issues.
>
>
> *Summary*
>
>
> Like it or not, Black is the de-facto standard for formatting Python 
> programs. The Ruff Format 
> 
>  tool 
> emulates Black's operation.
>
>
> Imo, Leo should *always *write Black-compatible sentinels. Doing so will 
> remove a reason for not using Leo! 
>
>
> Leonine projects (including Leo!) will notice large diffs when Leo 
> converts sentinel comments to the Black-compatible format. These diffs are 
> a *one-time* cost of this proposal.
>
>
> Afaik, this proposal has no other negative consequences.
>
>
> Your comments, please.
>
>
> 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/929a5386-9ce7-4403-8431-29d79ad027dcn%40googlegroups.com.


Re: Silly/crazy problem with sqlite

2023-11-25 Thread Thomas Passin via Python-list

On 11/24/2023 4:49 PM, Rimu Atkinson via Python-list wrote:







I really can't think of a case
where the missing comma would make any sense at all.



That is pretty tricky, yes.

The comma means it's a tuple. Without the comma, it's just a string with 
parenthesis around it, which is a string.


PyDev console: starting.
Python 3.9.15 (main, Oct 28 2022, 17:28:38) [GCC] on linux
x = ('%' + "2023-11" + '%')
x
'%2023-11%'
x = ('%' +  x + '%',)
x
('%%2023-11%%',)
x.__class__.__name__
'tuple'


To make it very clear in your code so that you are reminded next time 
you want to re-use it, you could write


param = '%2023-11%'
cr.execute(sql, (param,))

Probably the param value will actually use a variable instead of the 
hard-coded value in the example. So use an f-string, because it's more 
readable and easier to get right:


date = ... # Where ever the actual date value comes from
param = f'%{date}%'
cr.execute(sql, (param,))

--
https://mail.python.org/mailman/listinfo/python-list


Re: Scripts For Using Current Directory Updated

2023-11-22 Thread Thomas Passin
OK, here they are.

Here's an example of how they can be used. You have a node and you want to 
have some images that you can display with, say, VR3.  You want to put them 
into an *images* subdir, but you have to navigate there first.  How can you 
do that?  With the *show-current-dir* button you just click it and the 
system's file manager/Windows Explorer window opens on that directory. Now 
you can copy those image files to the *images* subdirectory.

On Wednesday, November 22, 2023 at 11:38:36 AM UTC-5 Edward K. Ream wrote:

> On Wed, Nov 22, 2023 at 9:57 AM Thomas Passin  wrote:
>
> >> Would you like to contribute these scripts to Leo?
>
> > Certainly.  I use them a lot. 
>
> > Where should they go in the Leo code base? 
>
> Please send them to me in a small .leo file. I'll figure it out :-)
>
> 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/42fb9242-808c-4e9a-b6e0-2bbd9434809en%40googlegroups.com.


https://leo-editor.github.io/leo-editor/namespaces/leo-python-editor/1.1"; >





Tom Passin's Current Directory Buttons
@button Show Current Dir
@button Cmd Window Here
@button Node Dir to Clip




@language python
"""Open directory for a node, respecting any @path directives and "~"."""

from pathlib import Path
from subprocess import run

pth = Path(c.fullPath(p))
if pth.exists():
if pth.is_file():
direc = pth.parent
else:
direc = pth
else:
direc = Path(g.scanAllAtPathDirectives(c, p))

if direc:
normdir = str(direc.resolve())
term = 'explorer.exe' if g.isWindows else 'xdg-open'
run([term, direc])

else:
g.es(f"Path {direc} doesn't exist", color='red')

@language python
"""Open command window at current directory. Expands "~"."""

from pathlib import Path
from subprocess import run

pth = Path(c.fullPath(p))
if pth.exists():
if pth.is_file():
direc = pth.parent
else:
direc = pth
else:
direc = Path(g.scanAllAtPathDirectives(c, p))

if direc:
normdir = str(direc.resolve())
if g.isWindows:
cmd = f'start cmd.exe /K "cd {direc}"'
run(cmd, shell=True)
else:
cmd = 'x-terminal-emulator'
run(cmd, cwd=direc)
else:
g.es(f"Path {direc} doesn't exist", color='red')
@language python
"""Copy the effective path of the current node to the clipboard.

This command honors @path directives.
"""
from pathlib import Path

pth = Path(c.fullPath(p))
if pth.exists():
if pth.is_file():
direc = pth.parent
else:
direc = pth
else:
direc = Path(g.scanAllAtPathDirectives(c, p))

if direc:
normdir = str(direc.resolve())
g.app.gui.replaceClipboardWith(normdir)
else:
g.es(f"Path {direc} doesn't exist")






Re: Scripts For Using Current Directory Updated

2023-11-22 Thread Thomas Passin
On Wednesday, November 22, 2023 at 9:58:53 AM UTC-5 Edward K. Ream wrote:

On Wed, Nov 22, 2023 at 8:45 AM Thomas Passin  wrote:

Some time ago I added a few scripts in the form of *@button* nodes that did 
useful things with the outline's current directory:


Would you like to contribute these scripts to Leo?


Certainly.  I use them a lot.  In fact, sometimes I don't know how I 
managed without them. I have them in my myLeoSettings.leo outline so all 
outlines can use them.

Where should they go in the Leo code base? They are already in the 
leo-editor-contrib outline, but I suppose not many people will find them 
there.

-- 
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/edd55533-0aa9-4dfc-8ea2-7b0402164762n%40googlegroups.com.


Scripts For Using Current Directory Updated

2023-11-22 Thread Thomas Passin
Some time ago I added a few scripts in the form of *@button* nodes that did 
useful things with the outline's current directory:

- Open a command window/terminal at the current directory;
- Open a file manager window at the current directory;
- Copy the current directory to the clipboard.

"Current directory" means the directory in effect at the selected node - 
e.g., *@path*, *@file*, etc., otherwise the outline's directory.

The Leo method used by these scripts changed and caused these scripts to 
sometimes go to the parent directory instead.

I've changed the code to work as intended, and I changed from using the 
os.path library to pathlib.

These changes have been merged into the "master" branch of 
TomPassinScripts.leo in the leo-editor-contrib repo on GitHub.

-- 
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/16d518c7-c710-46bc-ae27-6a5d9333d11an%40googlegroups.com.


Re: Autosave functionality does not appear to work

2023-11-22 Thread Thomas Passin
I believe you need to enable the mod_autosave.py plugin before those 
settings will take effect.  Add a line to the  @*enabled-plugins* node in 
myLeoSettings.leo:

mod_autosave.py

Then restart Leo.

If the node doesn't exist, copy it from leoSettings.leo and make your 
change.

On Wednesday, November 22, 2023 at 8:36:38 AM UTC-5 Thomas Passin wrote:

Without commenting on the autosave matter, don't go changing 
leoSettings.leo.  That can change with new releases and your changes will 
get lost.  Put your changes into myLeoSettings.leo.  They will override any 
settings of the same name in leoSettings.leo.

-- 
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/df587869-15a4-4a5c-bd12-863592bb6064n%40googlegroups.com.


Re: Autosave functionality does not appear to work

2023-11-22 Thread Thomas Passin
On Wednesday, November 22, 2023 at 2:22:45 AM UTC-5 terrence...@gmail.com 
wrote:


I then navigated to *Settings -> open LeoSettings.leo*

HOWEVER it actually opens a leoSettings.leo not LeoSettings.leo file in 
c:\code\leo-editor\leo\config

I set the autosave interval to 3 seconds and then made a small change to 
the node
"About this file, leoSettings.leo"

and 30 seconds later, it still has not saved the file.


Without commenting on the autosave matter, don't go changing 
leoSettings.leo.  That can change with new releases and your changes will 
get lost.  Put your changes into myLeoSettings.leo.  They will override any 
settings of the same name in leoSettings.leo.

-- 
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/c99c8dd5-1a94-4e93-8ffa-7983cd040c56n%40googlegroups.com.


Re: 🛠️ LeoJS status 🏗️

2023-11-21 Thread Thomas Passin
Looking forward to it.

On Saturday, November 18, 2023 at 4:57:19 AM UTC-5 Edward K. Ream wrote:

> On Fri, Nov 17, 2023 at 9:20 PM Félix  wrote:
>
> Just a small status update to keep the morale of the troops up!
>
>
> Many thanks for this update.  And for your attention to detail.
>
> The delay is worthwhile. So is the news that very little remains, hehe!
>
> 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/de672afb-32bb-45dc-beca-0bb97bd7fd46n%40googlegroups.com.


Re: 🛠️ LeoJS status 🏗️

2023-11-17 Thread Thomas Passin
Good work, Felix! Cheer up, there will be ten times more bugs than you 
expect. It's just the normal way of the world.

On Friday, November 17, 2023 at 10:20:19 PM UTC-5 Félix wrote:

> Just a small status update to keep the morale of the troops up!
>
> I've finally made the dreaded leoCache.ts code work line by line like the 
> original python. the multiple layers of encoding/zipping/pickling/sqlite 
> shenanigans and tricky object classes  implementation were quite a 
> challenge! 
>
> Now the only small remaining issue(s) I want to fix before the first alpha 
> release is small details in section references of @clean nodes. (works in 
> other types of @file nodes so its probably a detail.) 
>
> Just regular small/tricky bug hunting, no big chunk of code to write! 
>
> Stay tuned ! :D
>
> Félix
> [image: leojs-sticker-kids.png]
>

-- 
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/35112a1a-3afd-4630-99ba-6205f9ca169dn%40googlegroups.com.


Re: Code improvement question

2023-11-17 Thread Thomas Passin via Python-list

On 11/17/2023 9:46 AM, Peter J. Holzer via Python-list wrote:

On 2023-11-17 07:48:41 -0500, Thomas Passin via Python-list wrote:

On 11/17/2023 6:17 AM, Peter J. Holzer via Python-list wrote:

Oh, and Python (just like Perl) allows you to embed whitespace and
comments into Regexps, which helps readability a lot if you have to
write long regexps.


[...]

re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)


\b - a word boundary.
[0-9]{2,7} - 2 to 7 digits
-  - a hyphen-minus
[0-9]{2}   - exactly 2 digits
-  - a hyphen-minus
[0-9]{2}   - exactly 2 digits
\b - a word boundary.

Seems quite straightforward to me. I'll be impressed if you can write
that in Python in a way which is easier to read.


And the re.VERBOSE (also re.X) flag can always be used so the entire
expression can be written line-by-line with comments nearly the same
as the example above


Yes. That's what I alluded to above.


I know, and I just wanted to make it explicit for people who didn't know 
much about Python regexes.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Code improvement question

2023-11-17 Thread Thomas Passin via Python-list

On 11/17/2023 6:17 AM, Peter J. Holzer via Python-list wrote:

On 2023-11-16 11:34:16 +1300, Rimu Atkinson via Python-list wrote:

Why don't you use re.findall?

re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)


I think I can see what you did there but it won't make sense to me - or
whoever looks at the code - in future.

That answers your specific question. However, I am in awe of people who
can just "do" regular expressions and I thank you very much for what
would have been a monumental effort had I tried it.


I feel the same way about regex. If I can find a way to write something
without regex I very much prefer to as regex usually adds complexity and
hurts readability.


I find "straight" regexps very easy to write. There are only a handful
of constructs which are all very simple and you just string them
together. But then I've used regexps for 30+ years, so of course they
feel natural to me.

(Reading regexps may be a bit harder, exactly because they are to
simple: There is no abstraction, so a complicated pattern results in a
long regexp.)

There are some extensions to regexps which are conceptually harder, like
lookahead and lookbehind or nested contexts in Perl. I may need the
manual for those (especially because they are new(ish) and every
language uses a different syntax for them) or avoid them altogether.

Oh, and Python (just like Perl) allows you to embed whitespace and
comments into Regexps, which helps readability a lot if you have to
write long regexps.



You might find https://regex101.com/ to be useful for testing your regex.
You can enter in sample data and see if it matches.

If I understood what your regex was trying to do I might be able to suggest
some python to do the same thing. Is it just removing numbers from text?


Not "removing" them (as I understood it), but extracting them (i.e. find
and collect them).


re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)


\b - a word boundary.
[0-9]{2,7} - 2 to 7 digits
-  - a hyphen-minus
[0-9]{2}   - exactly 2 digits
-  - a hyphen-minus
[0-9]{2}   - exactly 2 digits
\b - a word boundary.

Seems quite straightforward to me. I'll be impressed if you can write
that in Python in a way which is easier to read.


And the re.VERBOSE (also re.X) flag can always be used so the entire 
expression can be written line-by-line with comments nearly the same as 
the example above


--
https://mail.python.org/mailman/listinfo/python-list


Re: Newline (NuBe Question)

2023-11-16 Thread Thomas Passin via Python-list

On 11/16/2023 1:19 AM, Grizzy Adams via Python-list wrote:

Wednesday, November 15, 2023  at 15:54, Thomas Passin via Python-list wrote:
Re: Newline (NuBe Question) (at least in part)


On 11/15/2023 2:04 PM, Grizzy Adams via Python-list wrote:

Wednesday, November 15, 2023  at 12:19, Pierre Fortin wrote:
Re: Newline (NuBe Question) (at least in part)
  

On Wed, 15 Nov 2023 16:51:09 - Grizzy Adams via Python-list wrote:



I don't give solutions; just a nudge...  you appear not to fully grok
"list"; your list is ONE list with no delineation between students. You
want a "list of lists"...
  

['Example High', 'Mary', 89.6, 'Pass', 'Example High', 'Matthew', 76.5, 'Fail', 
'Example High', 'Marie', 80.4, 'Fail', 'Example High', 'Manuel', 79.6, 'Fail', 
'Example High', 'Malala', 98.9, 'Pass']



Like this:
  

students = [
 ['Example High', 'Mary', 89.6, 'Pass'],
 ['Example High','Matthew', 76.5, 'Fail'],
 ['Example High', 'Marie', 80.4, 'Fail'],
 ['Example High', 'Manuel', 79.6, 'Fail'],
 ['Example High', 'Malala', 98.9, 'Pass']
]
  

for now I made a copt of code and altered to

students = []
grades = []



# In this design there is no point in the extra loop.
# also, the indentation is wrong.  Perhaps you inserted
# tabs?  Use only spaces in these posts.


I copy-pasted the code direct from IDLE, (to avoid any other typo's)


# Also you don't need the students list

for student in geographyClass:
# students.append(geographyStudent(s))

 s = geographyStudent(student)



  # for s in students:

   if s.finalGrade()>82: Result=("Pass")
   else: Result=("Fail")
   print(s.school, s.name, s.finalGrade(),Result)


I'll hive this a try (as a learning point)


I wrote that you don't need the "students" list, which is correct.  But 
there could be a use for a list.  It would let you change the order in 
which students appear in the printed output.  Knowing how to do that is 
a useful skill.  But that should be left for a later lesson, not mixed 
in here.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Newline (NuBe Question)

2023-11-15 Thread Thomas Passin via Python-list

On 11/15/2023 2:04 PM, Grizzy Adams via Python-list wrote:

Wednesday, November 15, 2023  at 12:19, Pierre Fortin wrote:
Re: Newline (NuBe Question) (at least in part)


On Wed, 15 Nov 2023 16:51:09 - Grizzy Adams via Python-list wrote:

I don't give solutions; just a nudge...  you appear not to fully grok
"list"; your list is ONE list with no delineation between students. You
want a "list of lists"...



['Example High', 'Mary', 89.6, 'Pass', 'Example High', 'Matthew', 76.5, 'Fail', 
'Example High', 'Marie', 80.4, 'Fail', 'Example High', 'Manuel', 79.6, 'Fail', 
'Example High', 'Malala', 98.9, 'Pass']



Like this:



students = [
['Example High', 'Mary', 89.6, 'Pass'],
['Example High','Matthew', 76.5, 'Fail'],
['Example High', 'Marie', 80.4, 'Fail'],
['Example High', 'Manuel', 79.6, 'Fail'],
['Example High', 'Malala', 98.9, 'Pass']
]


for now I made a copt of code and altered to

students = []
grades = []


# In this design there is no point in the extra loop.
# also, the indentation is wrong.  Perhaps you inserted
# tabs?  Use only spaces in these posts.
# Also you don't need the students list

for student in geographyClass:
# students.append(geographyStudent(s))

s = geographyStudent(student)



 # for s in students:

  if s.finalGrade()>82: Result=("Pass")
  else: Result=("Fail")
  print(s.school, s.name, s.finalGrade(),Result)


This may help get you headed in the right direction:



for s in students:
print( s )



Hint: look forward to learning about f-strings...


I will look forward to them, may even go search ahead,


--
https://mail.python.org/mailman/listinfo/python-list


Re: Newline (NuBe Question)

2023-11-15 Thread Thomas Passin via Python-list

On 11/15/2023 2:25 AM, Grizzy Adams via Python-list wrote:

Hi & thanks for patience with what could be simple to you

Have this (from an online "classes" tutorial)

--- Start Code Snippit  ---

students = []
grades = []
for s in geographyClass:
students.append(geographyStudent(s))
for s in students:
 grades.append(s.school)
 grades.append(s.name)
 grades.append(s.finalGrade())
 if s.finalGrade()>82:
 grades.append("Pass")
 else:
 grades.append("Fail")
print(grades)

--- End Code Snippit  ---

I have extended (from tutorial) it a bit, I would really like to have a newline

at end of each record, I have searched (and tested) but cant get "\n" to give a

newline, I get "Mydata\n"

Do I need to replace "append" with "print", or is there a way to get the
newline in as I append to list?


First of all, if this is an accurate representation of the course 
material, you need a better course.  There's no sense in appending all 
those values one after another in a single list since later it will be 
very inconvenient to detect the end of one student's info and the start 
of the next one's.  And if you don't need to know that, but just want to 
print out the data, you don't need to a list at all, just print it out 
in the loop.


A list that contains lists of each student's data, one per interior 
list, would make more sense.


Second, it is usual to append data to a list without print formatting, 
and then add your formatting when you go to print the list.  That way 
you can use the list for other things beyond just printing, and the code 
is clearer and simpler as well.


You may see responses that suggest various code alternatives.  But you 
haven't shown us an example of what you want the output to look like, 
and you haven't said what else you plan to use the list for.  So anyone 
who responds has to fly blind, without knowing key information.


Asking for help is like writing code, with an added social element.  You 
have to be clear about the requirements, inputs, and desired outputs, 
and you have to organize your request in a way that's easy for others to 
understand and be willing to help.  Your original post is partway there 
already.


--
https://mail.python.org/mailman/listinfo/python-list


Re: PR #3564 (beautify only changed files) merged into devel

2023-11-15 Thread Thomas Passin
I haven't really been aware of it.  I'm always leery of forced or automatic 
formatting changes, so I like to be able to say when I want it to happen.

On Wednesday, November 15, 2023 at 8:14:24 AM UTC-5 Edward K. Ream wrote:

> PR #3654  allows a 
> significant performance to my workflow.
>
> Without the *new --force option*, Leo's beautifier command only 
> beautifies files that git marks as changed. In practice, *this speeds up 
> beautification by at least 10x*.
>
> The PR also beautifies all of Leo's plugins. This should have been done 
> ages ago.
>
> I'm wondering: does anyone besides myself use Leo's beautifier?
>
> 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/8d7a8e95-7caf-4f7b-be53-85d0dcc995a8n%40googlegroups.com.


Re: xor operator (DEPRECATED)

2023-11-13 Thread Thomas Passin via Python-list

On 11/13/2023 11:44 PM, AVI GROSS via Python-list wrote:

Dom,

I hear you.

As you say, writing your own extension in something like C++ may not appeal to 
you even if it is faster.

I was wondering if using a generator or something similar in R might make sense.

I mean what happens if you write a function that includes a "yield" or two and 
does a part of what you want. It maintains some internal state between invocations. So 
you can call it once to setup things then call it repeatedly to keep processing the next 
item. You stop calling it when you get a result you want, such as that it has seen what 
you want N times.

Since the code stays in memory, it may effectively run faster than some other 
kinds of functions calls. It can keep things in internal storage such as not 
just how many N you want but how many it has seen.


I'm inclined to just turn the iterable into a set to get the values, 
then iterate through those values calling count() on a listified version 
of the iterable. If the count >= target, return.


It may not be the fastest one could do but it's simple and probably 
pretty fast for many uses.  I suppose that for some iterables it would 
be better not to turn them into lists, but one could figure out about 
that after working out more carefully what cases need to be covered.



Your outer function can maintain a list of the items you want to XOR or 
generate a new one dynamically as needed. It can use functional programming 
techniques to create a new customized version of the iterator, such as with a 
value of N built in. You would then call the outer function and let it use the 
inner function till the result is available or until the data in the iterator 
runs out or perhaps other tweaks involving two way communication of sorts 
between the functions.

I am NOT suggesting this approach is optimal or fast but merely wondering if 
something along these lines is worth trying that might speed things up even if 
not very fast. Such approaches can be even more effective if what you are 
working on need not all be instantiated up front but can be dynamically 
calculated or incrementally read from files. With care, you can make multiple 
instantiations that each iterate over their own sets of data without 
interference.

Just a thought. In a sense, this can be a slightly decent substitute for the 
non-standard evaluation in R where you can arrange for lots of your data to not 
be interpreted till absolutely needed.



-Original Message-
From: Dom Grigonis 
Sent: Monday, November 13, 2023 10:12 PM
To: avi.e.gr...@gmail.com
Cc: Grant Edwards ; Python 
Subject: Re: xor operator (DEPRECATED)

Fair point. However, I gave it a shot for the following reason:

I couldn’t find a way to make such performant function. Using python builtin 
components still ends up several times slower than builtin `all`. Cython or 
numba or similar is not an option as they do not support `truth` values. Or if 
they do, it ends up slower than pure python variant.

So all what is left is writing a proper extension. Which I would prefer not to 
do for 1 function. I thought maybe `xor`, as in logical XOR functionality in 
its vanilla case could be compelling. And after doing a bit of search I see 
that very very few languages have that and it seems for a good reason.

Some that do: R, thats all I could find. Although some (if not many) went 
through the proposal phase. And yes, none of them have a function that I am 
proposing.

So yes, you are right, not a good proposal.

But there still seems to be the need for short-circuiting performant 
implementations in python space. The issue is that there are many variants of 
what might be needed while there is no efficient solution to sourcing 
predicates from python to lower level implementations. Someone mentioned that 
numpy experimented with such implementations in C, but they did not get 
anywhere with it.

The best I could come up with is cached numba for numpy problems, which does 
perform very well and more than worth it if function is re-used. It even ends 
up faster than cython or cffi extensions, however can’t have many of those due 
to JIT and AOT is currently being deprecated (which wouldn’t solve anything 
anyway). However, as I mentioned earlier it does not apply to this case.

So it’s either:
a) Something very clever and flexible implemented that covers most of such 
needs and doesn’t require predicates.
b) I welcome any thoughts on this.

DG


On 14 Nov 2023, at 04:27, AVI GROSS via Python-list  
wrote:

I was going to ask a dumb question. Has any other language you know of made
something available that does what is being asked for and included it in the
main program environment rather than an add-on?

A secondary mention here has been whether short-circuiting functions like
"any" and "all" have been augmented with something like "has_n" that
evaluates arguments till it has found n or perhaps n+1 of what it wants then
skips the rest. Does any language

Re: [share] Cursorless - Structural voice coding at the speed of thought

2023-11-10 Thread Thomas Passin
That's really interesting.  And yet I would not be able to use it.  Marking 
each token semi-unobtrusively is cool, but I am fairly red-green color 
blind and can't distinguish or in some cases even recognize the colors of 
those dots.  The areas of the token markers would have to be much larger, 
and even then I would probably have to have larger differences between the 
various hues.

Around 15% of the population has some form of color blindness (mostly men) 
so there needs to be some clever thinking to be able to accommodate them.

On Friday, November 10, 2023 at 5:53:17 AM UTC-5 iamap...@gmail.com wrote:

> I never heard this before:
>
> https://marketplace.visualstudio.com/items?itemName=pokey.cursorless
> Title: Cursorless - Visual Studio Marketplace
>
> https://xeiaso.net/notes/cursorless-alien-magic/
> Title: Cursorless is alien magic from the future - Xe Iaso
>
>

-- 
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/870fc38b-e9c8-462c-9988-fb95d684caaen%40googlegroups.com.


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread Thomas Passin via Python-list

On 11/7/2023 3:29 PM, MRAB via Python-list wrote:

On 2023-11-07 19:20, Jim Schwartz via Python-list wrote:
Where do you define fCONV_AUSRICHTG? It must be initialized or defined 
somewhere. Did you leave out a statement from the python 2 version?



It's given its value here:

     (
     fNAME,
     fLG1,
     fLG2,
     fTYP,
     fCONV_AUSRICHTG,
     fENTRY_AUSRICHTG,
     fTEXT_AUSRICHTUNG,
     fHOLFUNKT,
     fPRUEFFUNKT,
     fPRUEF_ARG,
     ) = list(range(10))



This construction is a sneaky way to assign index numbers to list 
entries.  A simplified example:


>>> S1 = 'string 1'
>>> S2 = 'string 2'
>>> (fS1, fS2) = list(range(2))
>>> fS1
0
>>>
>>> fS2
1





On Nov 7, 2023, at 1:06 PM, Thomas Passin via Python-list 
 wrote:


On 11/7/2023 12:47 PM, Egon Frerich via Python-list wrote:
I've no idea why this happens. In a module there are lists and 
definitions:

    Felder = [
    # Name   lg1  lg2 typ   Ausrichtung Holen Prüfen Prüfvorg
    ["Jahr", 4, 5, "u", "", "right", "center"],
    ["Monat", 2, 5, "u", "", "right", "center"],
    ["Tag", 2, 3, "u", "", "right", "center"],
    ["Belegnr", 5, 7, "s", "", "right", "center"],
    ["Bank", 2, 4, "u", "", "center", "center"],
    ["Art", 2, 3, "u", "", "center", "center"],
    ["Aufg", 2, 4, "u", "", "center", "center"],
    ["Text", 25, 25, "s", "-", "left", "left"],
    ["Ergänzung", 12, 12, "s", "-", "left", "left"],
    ["Betrag", 13, 13, "s", "", "right", "right"],
    ["W", 1, 2, "s", "", "center", "center"],
    ["WBetrag", 7, 7, "s", "", "right", "right"],
    ["Kurs", 6, 6, "s", "", "right", "right"],
    ]
    "Reihenfolge in der Dimension 1"
    (
    fJAHR,
    fMONAT,
    fTAG,
    fBELEGNR,
    fBANK,
    fART,
    fAUFGABE,
    fTEXT,
    fTEXTERG,
    fBETRAG,
    fWAEHRUNG,
    fBETRAGinWAEHRUNG,
    fUMRECHNUNGSKURS,
    ) = list(range(13))
    "Reihenfolge in der Dimension 2"
    (
    fNAME,
    fLG1,
    fLG2,
    fTYP,
    fCONV_AUSRICHTG,
    fENTRY_AUSRICHTG,
    fTEXT_AUSRICHTUNG,
    fHOLFUNKT,
    fPRUEFFUNKT,
    fPRUEF_ARG,
    ) = list(range(10))
Two lines with  test statements follow and the statement which 
produces an error:

    print(Felder)
    print(fJAHR, fNAME, fTYP, fCONV_AUSRICHTG)
    akette = "%" + "%".join(
    ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in 
Felder])

The traceback shows:
$ python3 testGeldspurGUI.py
[['Jahr', 4, 5, 'u', '', 'right', 'center'], ['Monat', 2, 5, 'u', 
'', 'right', 'center'], ['Tag', 2, 3, 'u', '', 'right', 'center'], 
['Belegnr', 5, 7, 's', '', 'right', 'center'], ['Bank', 2, 4, 'u', 
'', 'center', 'center'], ['Art', 2, 3, 'u', '', 'center', 'center'], 
['Aufg', 2, 4, 'u', '', 'center', 'center'], ['Text', 25, 25, 's', 
'-', 'left', 'left'], ['Ergänzung', 12, 12, 's', '-', 'left', 
'left'], ['Betrag', 13, 13, 's', '', 'right', 'right'], ['W', 1, 2, 
's', '', 'center', 'center'], ['WBetrag', 7, 7, 's', '', 'right', 
'right'], ['Kurs', 6, 6, 's', '', 'right', 'right']]

0 0 3 4
Traceback (most recent call last):
  File "/home/egon/Entw/Geldspur/geldspur/testGeldspurGUI.py", line 
15, in 

    from tests.testU2 import testU2
  File "/home/egon/Entw/Geldspur/geldspur/tests/testU2.py", line 9, 
in 

    from gui.GUI_Konfig import GUIcfg
  File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 
11, in 

    class GUIcfg:
  File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 
90, in GUIcfg
    ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in 
Felder])
  File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 
90, in 
    ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in 
Felder])

NameError: name 'fCONV_AUSRICHTG' is not defined
You see "Felder" and with "0 0 3 4" the correct value 4 for 
fCONV_AUSRICHTG. But there is the NameError.

What does  mean? Is there a change from python2 to python3?


You are using a syntax that I don't understand, but "listcomp" means 
a list comprehenson.






--
https://mail.python.org/mailman/listinfo/python-list


Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread Thomas Passin via Python-list

On 11/7/2023 12:47 PM, Egon Frerich via Python-list wrote:

I've no idea why this happens. In a module there are lists and definitions:

     Felder = [
     # Name   lg1  lg2 typ   Ausrichtung Holen Prüfen Prüfvorg
     ["Jahr", 4, 5, "u", "", "right", "center"],
     ["Monat", 2, 5, "u", "", "right", "center"],
     ["Tag", 2, 3, "u", "", "right", "center"],
     ["Belegnr", 5, 7, "s", "", "right", "center"],
     ["Bank", 2, 4, "u", "", "center", "center"],
     ["Art", 2, 3, "u", "", "center", "center"],
     ["Aufg", 2, 4, "u", "", "center", "center"],
     ["Text", 25, 25, "s", "-", "left", "left"],
     ["Ergänzung", 12, 12, "s", "-", "left", "left"],
     ["Betrag", 13, 13, "s", "", "right", "right"],
     ["W", 1, 2, "s", "", "center", "center"],
     ["WBetrag", 7, 7, "s", "", "right", "right"],
     ["Kurs", 6, 6, "s", "", "right", "right"],
     ]
     "Reihenfolge in der Dimension 1"
     (
     fJAHR,
     fMONAT,
     fTAG,
     fBELEGNR,
     fBANK,
     fART,
     fAUFGABE,
     fTEXT,
     fTEXTERG,
     fBETRAG,
     fWAEHRUNG,
     fBETRAGinWAEHRUNG,
     fUMRECHNUNGSKURS,
     ) = list(range(13))
     "Reihenfolge in der Dimension 2"
     (
     fNAME,
     fLG1,
     fLG2,
     fTYP,
     fCONV_AUSRICHTG,
     fENTRY_AUSRICHTG,
     fTEXT_AUSRICHTUNG,
     fHOLFUNKT,
     fPRUEFFUNKT,
     fPRUEF_ARG,
     ) = list(range(10))


Two lines with  test statements follow and the statement which produces 
an error:


     print(Felder)
     print(fJAHR, fNAME, fTYP, fCONV_AUSRICHTG)
     akette = "%" + "%".join(
     ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in 
Felder])


The traceback shows:

$ python3 testGeldspurGUI.py
[['Jahr', 4, 5, 'u', '', 'right', 'center'], ['Monat', 2, 5, 'u', '', 
'right', 'center'], ['Tag', 2, 3, 'u', '', 'right', 'center'], 
['Belegnr', 5, 7, 's', '', 'right', 'center'], ['Bank', 2, 4, 'u', '', 
'center', 'center'], ['Art', 2, 3, 'u', '', 'center', 'center'], 
['Aufg', 2, 4, 'u', '', 'center', 'center'], ['Text', 25, 25, 's', '-', 
'left', 'left'], ['Ergänzung', 12, 12, 's', '-', 'left', 'left'], 
['Betrag', 13, 13, 's', '', 'right', 'right'], ['W', 1, 2, 's', '', 
'center', 'center'], ['WBetrag', 7, 7, 's', '', 'right', 'right'], 
['Kurs', 6, 6, 's', '', 'right', 'right']]

0 0 3 4
Traceback (most recent call last):
   File "/home/egon/Entw/Geldspur/geldspur/testGeldspurGUI.py", line 15, 
in 

     from tests.testU2 import testU2
   File "/home/egon/Entw/Geldspur/geldspur/tests/testU2.py", line 9, in 


     from gui.GUI_Konfig import GUIcfg
   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 11, 
in 

     class GUIcfg:
   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 90, 
in GUIcfg

     ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in Felder])
   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 90, 
in 

     ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in Felder])
NameError: name 'fCONV_AUSRICHTG' is not defined

You see "Felder" and with "0 0 3 4" the correct value 4 for 
fCONV_AUSRICHTG. But there is the NameError.


What does  mean? Is there a change from python2 to python3?


You are using a syntax that I don't understand, but "listcomp" means a 
list comprehenson.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Writing to clipboard in Python 3.11

2023-11-07 Thread Thomas Passin via Python-list

On 11/5/2023 7:51 PM, Rob Cliffe via Python-list wrote:
Recently I switched from Python 3.8.3 to Python 3.11.4.  A strange 
problem appeared which was not there before:
I am using the win32clipboard backage (part of pywin32), and when I use 
SetClipboardData() to write text which consists ENTIRELY OF DIGITS to 
the clipboard, I either get an error (not always the same error message) 
or a program crash.  The problem does not appear if I use 
SetClipboardText() instead.

Sample program:

from win32clipboard import *
OpenClipboard()
SetClipboardData(CF_UNICODETEXT, "A")
SetClipboardData(CF_UNICODETEXT, "A0")
SetClipboardData(CF_UNICODETEXT, "0A")
SetClipboardText("0", CF_UNICODETEXT)
print("OK so far")
SetClipboardData(CF_UNICODETEXT, "0")
CloseClipboard()

Sample output:

OK so far
Traceback (most recent call last):
   File "R:\W.PY", line 8, in 
     SetClipboardData(CF_UNICODETEXT, "0")
pywintypes.error: (0, 'SetClipboardData', 'No error message is available')

I can get round the problem by using SetClipboardText().  But can anyone 
shed light on this?


No, but I use pyperclip.  It's cross platform.  Maybe it doesn't have 
this problem, though I don't know for sure.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Detect naming typos (AttributeError) in function names

2023-11-07 Thread Thomas Passin via Python-list

On 11/7/2023 2:48 AM, Christian Buhtz via Python-list wrote:

Hello Dieter,

thanks for your reply.

Am 06.11.2023 19:11 schrieb Dieter Maurer:

One option is a test suite (--> Python's "unittest" package)
with a sufficiently high coverage (near 100 %).


Yes, that is the primary goal. But it is far away in the related project.

I got a hint that "pylint" is able to detect problems like this.


mypy can detect typos in names by noticing that they haven't been 
declared.  For example, if you have a class NewClass(BaseClass), and 
BaseClass has a method findme(), but you call it as findMe(), mypy will 
tell you findMe does not exist in BaseClass.  It can be annoying to get 
the options set right so you don't get too many undesired hits, but it's 
certainly doable.  mypy can be slow, depending on your code.


You could also simply run py_compile, which will try to compile the 
code.  It will stop at the first error it finds.


--
https://mail.python.org/mailman/listinfo/python-list


Re: LLMs as Collaborators

2023-11-06 Thread Thomas Passin
Here's another installment of Jon Udell's LLM chat experiments -
Let’s Talk: Conversational Software Development 


On Friday, September 8, 2023 at 9:46:36 PM UTC-4 iamap...@gmail.com wrote:

> Learning While Coding: How LLMs Teach You Implicitly 
> 
>
> Very interesting, I like it. thanks for sharing!
>
> Here is the list of posts for someone who want read more :D
>
> https://blog.jonudell.net/2023/09/07/how-llms-teach-you-things-you-didnt-know-you-didnt-know/
>  
>

-- 
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/f6605e2a-5fa2-4f0a-8d28-638fb31bbe9an%40googlegroups.com.


<    1   2   3   4   5   6   7   8   9   10   >