RE: A switch somewhere, or bug? CORRECTION

2025-12-05 Thread Em
Ok, using "Open with Python" , the program fails on both computers.
Still, double-click the filename on the WIN10 computer and the program
works.
While, double-click the filename on the WIN11 computer and the program
fails.

-Original Message-
From: Thomas Passin  
Sent: Friday, December 5, 2025 4:34 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION

On 12/5/2025 3:03 PM, Em wrote:
> Alright, Alright, Alright...
> Alright.
> 
> These responses push much more sophisticated explanations than the 
> question asked.  This involves only one line of code that creates an empty
text file.
> No other code is involved or needed.
> 
> Before responding, please run this test:
> 
> Create a .py file that contains the line:
> Starter = open("HLYlog.txt", "w")
> 
> Copy that file onto a folder in a WIN10 computer which uses Python 
> 3.13 and copy it again onto a folder in a WIN11 computer that runs 
> Python 3.14.1
> 
> Double-click the filename in the folder on the
> WIN10 computer. It executes the program and the text file is created.
> 
> Double-click the filename in the folder on the
> WIN11 computer and it fails, no text file is created.
> No error statement is generated.
> 
> The strange thing here is that, on the WIN11 computer, I right-click 
> and choose "Edit with IDLE" option.  The file code is shown and I 
> press F5.  The program runs properly and the text file is created.  Of 
> course, IDLE does not show an error report on a working program.
> 
> The medical program that I wrote, and have used for 20 years, works on 
> the WIN10 computer. I now want to copy it to the WIN11 computer and it 
> consistently fails on this line.
> 
> The change from WIN10 Python 3.13 to WIN11 Python 3.14 is the only 
> difference I can see.

You have been mixing up two things, and it's confusing to people who want to
help:

1. Running a .py file by double-clicking the .py file name in Windows
Explorer; 2. Whether or not your program works using this Python install,
when run from the command line in a Console.

Kindly try to run the program with Python from the command line. By that I
mean some variation of "py your_program.py". Of course, you first need to CD
to its directory; otherwise you have to include the full path. See if it
creates the file it's supposed to. If it does, delete the created file, and
try to run the program from the console just using the file's name,
*without* prefixing it with "py", "python" or whatever you used to run it
when it succeeded. You should see a new console flash up for a moment then
close and vanish.  See if the file was created.

Running by typing the .py file name by itself should will launch it the same
way it would be launched when you double click on the file name.

If the file was created when you ran your file with the python executable,
that verifies the program ran and functions.  Since it works in IDLE, that
should succeed.  Then if it fails when typing just the bare program name,
that would show that the file association for .py files isn't set up.
Unfortunately, the new console doesn't stay visible long enough to see any
error messages and you have to work around that fact to make sure of what is
going on.

Another way to check is to right-click on your .py file in Windows Explorer,
and go down to the "Open With" menu item. The first name in that list should
be some variation of "Python (Default)". If that's not the case, you need to
set up the file association using the Settings/Default apps settings page,
as I mentioned in an earlier post.

I suspect that the file association hasn't been set up.  That was the case
on my Windows 11 computer too.

> 
> 
> 
> 
> -Original Message-
> From: Michael Torrie via Python-list 
> Sent: Friday, December 5, 2025 1:18 PM
> To: [email protected]
> Subject: Re: A switch somewhere, or bug? CORRECTION
> 
> On 12/4/25 10:47 PM, Em wrote:
>>> Starter = open("HLYlog.txt", "w")
>>>
>>> Thoughts appreciated.
>>
>> -That's a relative path. Are you sure that the current working 
>> directory is what -you expect? It's generally better to work with 
>> absolute paths.
>>
>> Relative or not, I can't see how that could possibly make any difference.
> 
> You don't? Why? The key word is "working directory."  How do you know 
> what the working directory is? If you start a program using a shortcut 
> link, the link can specify any arbitrary directory.  If you start it 
> from idle, idle sets the working directory. If you double click the py 
> file, the pylauncher sets the working directory. All could be and in 
> fact 

RE: A switch somewhere, or bug? CORRECTION

2025-12-06 Thread Em


-Original Message-
From: Roel Schroeven  
Sent: Saturday, December 6, 2025 7:00 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION

Op 6/12/2025 om 20:51 schreef Em:
>> The confusing part here is that no one has indicated whether or not 
>> the statement fails in any of the six ways to run this program except me.
>> Am I the only one that has the problem?

>Sometimes it happens to me too that a script doesn't work, for whatever 
>reason. 

This is not a matter of "sometimes".  This it totally predictable and it 
happens for me every time depending how I run it.

I have narrowed it down to an extremely simple program:

Pause = input(" Start ")
Starter = open("HLY-LOG5.txt","w")
pause - input(" End ")

Out of the seven scenarios:

Four options work if you use:
 WIN10 and double click on the filename.
 WIN10 and open the file with IDLE and press F5.
 WIN11 and open the file with IDLE and press F5.
 WIN11 and activate it from the command prompt.

Three fail to work if you use:
  WIN11 and double-click on the filename.
  WIN11 and select "Open using Python".
  WIN10 and select "Open using Python". (This one totally surprised me.)

>What I then do is launch the script in a way that maximizes my chances to 
>discover >what's going wrong. E.g. I run the script from a command prompt. 
>Have you done >that yet? Have you seen my other post (from 2025-12-05)? Have 
>you tried my >suggestions? What where the results?

Although I am attempting to use the suggestions provided, they do little help 
if I don't know the scope of the problem.

Is it happening only on my computers?
No one, so far, has posted either way.


-- 
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: A switch somewhere, or bug? CORRECTION

2025-12-04 Thread Em




-Original Message-
From: MRAB  
Sent: Thursday, December 4, 2025 10:52 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION

On 04/12/2025 18:25, Em wrote:
> Two computers, both alike in dignity, in fair windows land, where we 
> set our scene..
>
> in Win10/Python 3.13 my program runs as well as can be expected. 
> However, on my new computer Win11/Python 3.14.1 there is a peculiarity.
>
> On the new machine, when I click on the file name, it immediately dumps
out.
> I go in with IDLE and it runs fine with no indication of any error.
>



> I believe this line is the culprit:
> Starter = open("HLYlog.txt", "w")
>
> Thoughts appreciated.

-That's a relative path. Are you sure that the current working directory is
what 
-you expect? It's generally better to work with absolute paths.

Relative or not, I can't see how that could possibly make any difference. It
worked on the Win10 computer for both double-tap on the file and when using
IDLE. It worked on the Win11 computer when activated through IDLE but not
when I double-tapped to activate it. On the WIN11 computer.

In other words, it worked on 3/4 of the methods and not on the one of the
four.

Did it work for you , for both techniques, on a Win11 computer?






> -Original Message-
> From: Thomas Wouters 
> Sent: Tuesday, December 2, 2025 3:47 PM
> To: [email protected]; [email protected]
> Subject: [RELEASE] Python 3.13.10 is now available!
>
>
> Python 3.13.10 is now available:
>
> https://www.python.org/downloads/release/python-31310/
>
> Python 3.13.10 is the tenth maintenance release of 3.13, containing 
> around
> 300 bugfixes, build improvements and documentation changes since 3.13.9.
>
> Enjoy the new release!
> --
> https://mail.python.org/mailman3//lists/python-list.python.org
>
> --
> https://mail.python.org/mailman3//lists/python-list.python.org
>

--
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: A switch somewhere, or bug? CORRECTION

2025-12-04 Thread Em


Two computers, both alike in dignity, in fair windows land, where we set our
scene..

in Win10/Python 3.13 my program runs as well as can be expected. However, on
my new computer Win11/Python 3.14.1 there is a peculiarity.

On the new machine, when I click on the file name, it immediately dumps out.
I go in with IDLE and it runs fine with no indication of any error.

I believe this line is the culprit:
Starter = open("HLYlog.txt", "w")

Thoughts appreciated.


-Original Message-
From: Thomas Wouters 
Sent: Tuesday, December 2, 2025 3:47 PM
To: [email protected]; [email protected]
Subject: [RELEASE] Python 3.13.10 is now available!


Python 3.13.10 is now available:

https://www.python.org/downloads/release/python-31310/

Python 3.13.10 is the tenth maintenance release of 3.13, containing around
300 bugfixes, build improvements and documentation changes since 3.13.9.

Enjoy the new release!
--
https://mail.python.org/mailman3//lists/python-list.python.org

--
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


A switch somewhere, or bug?

2025-12-04 Thread Em
Two computers, both alike in dignity, in fair windows land...

in Win10/Python 3.13 my program runs as well as can be expected. However, on
my new computer Win11/Python 3.14.1 there is a peculiarity.

On the new machine, when I click on the file name, it immediately dumps out.
I go in with IDLE and it runs fine with no indication of any error.

I believe this line is the culprit:
Starter = open(HLYlog.txt", "w")

Thoughts appreciated.


-Original Message-
From: Thomas Wouters  
Sent: Tuesday, December 2, 2025 3:47 PM
To: [email protected]; [email protected]
Subject: [RELEASE] Python 3.13.10 is now available!


Python 3.13.10 is now available:

https://www.python.org/downloads/release/python-31310/

Python 3.13.10 is the tenth maintenance release of 3.13, containing around
300 bugfixes, build improvements and documentation changes since 3.13.9.

Enjoy the new release!
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: Re: A switch somewhere, or bug? CORRECTION

2025-12-04 Thread Em
No changes. Run the file is the folder or run it using IDLE.

Copy the same file to the WIN10 Python 3.13 and both situations run as
expected.

Maybe the attached file might explain.

No BSOD. Permissions don't change.

 

I tried to send a file as an attachment, failed/rejected as spam.

Here it is as text. 

 

#===

 

"""

On my computer: Win11, Python 3.14.1

 

Double-click and run on the file".  You will see the first two lines
execute.

The screen will show "Start" and "Starter File". Hit  to resolve the
pause statement and the program crashes when it tries to create the
"HLY-LOG5" file. The last line, "End" is not printed. No file is created.

 

Press F5 to activate the program here in IDLE.  The program executes
properly and the empty file "HLY-LOG5" text file is created.

 

Why did it crash with the double-click?

"""

print ("Start")

pause = input("   Starter file")

Starter = open("HLY-LOG5.txt","w")

pause = input("End")

 

#==

 

 

Curious, will there be a version 3.14.15926?

 

 

 

 

 


A voice mail message recently left on my phone:
"Please call us back at:
16 billion 863 million 431 thousand and 125"

 

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


What is the tool used here?

2025-12-07 Thread Em
I see >, >>, and >>>, attached at the beginning of lines in messages.   I
doubt that they are placed manually and wonder how they are placed
automatically. How do I get said program?

 


A voice mail message recently left on my phone:
"Please call us back at:
16 billion 863 million 431 thousand and 125"

 

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: A switch somewhere, or bug? CORRECTION

2025-12-05 Thread Em
Alright, Alright, Alright...
Alright.

These responses push much more sophisticated explanations than the question
asked.  This involves only one line of code that creates an empty text file.
No other code is involved or needed.

Before responding, please run this test:

Create a .py file that contains the line:
Starter = open("HLYlog.txt", "w")

Copy that file onto a folder in a WIN10 computer 
which uses Python 3.13 and copy it again onto a folder 
in a WIN11 computer that runs Python 3.14.1

Double-click the filename in the folder on the 
WIN10 computer. It executes the program and the 
text file is created.

Double-click the filename in the folder on the 
WIN11 computer and it fails, no text file is created.
No error statement is generated.

The strange thing here is that, on the WIN11 computer, 
I right-click and choose "Edit with IDLE" option.  The file 
code is shown and I press F5.  The program runs properly 
and the text file is created.  Of course, IDLE does not 
show an error report on a working program.

The medical program that I wrote, and have used for 20 years, 
works on the WIN10 computer. I now want to copy it 
to the WIN11 computer and it consistently fails on
this line.

The change from WIN10 Python 3.13 to WIN11 Python 3.14
is the only difference I can see.





-Original Message-
From: Michael Torrie via Python-list  
Sent: Friday, December 5, 2025 1:18 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION

On 12/4/25 10:47 PM, Em wrote:
>> Starter = open("HLYlog.txt", "w")
>>
>> Thoughts appreciated.
> 
> -That's a relative path. Are you sure that the current working 
> directory is what -you expect? It's generally better to work with 
> absolute paths.
> 
> Relative or not, I can't see how that could possibly make any difference. 

You don't? Why? The key word is "working directory."  How do you know what
the working directory is? If you start a program using a shortcut link, the
link can specify any arbitrary directory.  If you start it from idle, idle
sets the working directory. If you double click the py file, the pylauncher
sets the working directory. All could be and in fact are different.  If you
always want it to open that file in the same directory as the script, then
you can use code such as the following:

import os

# Get the absolute path of the current python file we're running
current_file_path = os.path.abspath(__file__)

# Get the directory of the current file
current_directory = os.path.dirname(current_file_path)

print(f"The directory of the current file is: {current_directory}")

(disclaimer, suggested by  AI, verified by me to be correct).
--
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: A switch somewhere, or bug? CORRECTION

2025-12-07 Thread Em




Footnote:
Fifteen plus Fifteen is thirty.
Sixteen and Sixteen is thirty too.

-Original Message-
From: MRAB  
Sent: Saturday, December 6, 2025 9:59 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION



On 07/12/2025 00:54, Thomas Passin wrote:
> On 12/6/2025 6:49 PM, Em wrote:
>> For at least the last 10 years. I have been using double click on the 
>> filename (or by shortcut) to use the program. It tracks the Insulin 
>> injections for me and creates/updates several text files. I have been 
>> using IDLE for editing on WIN10 computers.  No issues
>>
>> When I copied the file to the new WIN11 computer and double-click on 
>> the filename, it fails without warning or explanation.  In WIN11, I 
>> can open the file with IDLE and use F5 to run it successfully.
>>
>> I was told to try "Open with Python" and it fails on both the WIN10 
>> and
>> WIN11 computers.  I do not see the option for this program to Run as 
>> Administrator on either computer.  I have seen/used Run as 
>> Administrator elsewhere on the WIN10 computer.
>>
>> I created a .py program with the lines of code:
>>
>> pause = input("Start")
>> Starter = open("HLY-LOG5.txt","w")
>> pause = input("End")
>>
>> and can follow all six of the techniques to run as mentioned above. 
>> Three situations, the program runs, and three have the program fail.
>> Exactly the
>> same results as with my medical program.
>>
>> Has my short, three line, program worked on your system?
>
> You should have sent this message to the group, not just me. Yes, your 
> program created the file but not when I double-clicked on the file 
> name.  As I explained in my last post, that's because in Windows 11 
> when double-clicking, the working directory is the system's Windows 
> directory, not the one your program is in. In Win 11, you don't have 
> access to it as an ordinary user.  Anyway even if you did, you don't 
> want to write your file there.
>
> There's a simple solution if you want to be able to launch by double 
> clicking the file.  Actually, there are at least four ways to go.
>
> 1. Run your program using a batch file.  in the batch file, cd to your 
> target directory before launching your program.  The batch file needs 
> to be somewhere on your path, or alternatively you can put a shortcut 
> to it on your desktop.
>
> If you don't know how to do any of those things, ask for help.
>
> 2. Make your Python program change directories to the target directory 
> before writing the file. I think someone already posted a code snippet 
> showing how to do that. If not, and you don't know how, ask for help.
>
> 3. Hard-code the full path to your target file.  Then it won't matter 
> what working directory is in effect.
>
> 4.Create a shortcut for your .py file on the desktop. Then open the 
> Properties dialog for the shortcut. In the "Shortcut" tab you can put 
> the desired working directory.  Now when you double click the 
> shortcut, it will open in the right directory.
>

So, is this a change from WIN10?
and is IDLE not affected by this change?

And what use is the following from MRAB:


I always find a script's location with `__file__`.

If "HLY-LOG5.txt" is in the same folder as the script, then its path is given 
by:

 from os.path import dirname, join

 log_path = join(dirname(__file__), "HLY-LOG5.txt")

--
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: A switch somewhere, or bug? CORRECTION

2025-12-07 Thread Em




-Original Message-
From: Roel Schroeven  
Sent: Sunday, December 7, 2025 7:23 AM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION

Op 7/12/2025 om 1:54 schreef Thomas Passin:
>> As I explained in my last post, that's because in Windows 11 when 
>> double-clicking, the working directory is the system's Windows 
>> directory, not the one your program is in.

>Irrespective of anything else that's going on, that's not my experience. 
>I just tried, and double-clicking a python script makes the 
>directory that I have open in Explorer the current directory. 
>I've seen the same not just with scripts but also with executables. 
>I don't think this is the cause.

Interesting. So, your system is corrected for this and mine, I guess, is not.
For me, it fails each and every time I use a phrase like that in any program in 
WIN11.
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: A switch somewhere, or bug? CORRECTION

2025-12-06 Thread Em


The confusing part here is that no one has indicated whether or not the
statement fails in any of the six ways to run this program except me.

Am I the only one that as the problem?

-Original Message-
From: Peter J. Holzer  
Sent: Saturday, December 6, 2025 12:56 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION

On 2025-12-04 18:03:34 -0500, Em wrote:
   ^^
   Weird. That was before most of the thread (and the message wasn't stuck
in a moderation queue), yet it seems everybody ignored this message. .
Probably because it isn't actually part of the thread, but ...

> On my computer: Win11, Python 3.14.1
> 
>  
> 
> Double-click and run on the file".  You will see the first two lines 
> execute.
> 
> The screen will show "Start" and "Starter File".

Good. So we know that the program is executed.

> Hit  to resolve the
> pause statement and the program crashes when it tries to create the 
> "HLY-LOG5" file. The last line, "End" is not printed. No file is created.

So the next step is to find out why it isn't executed. First print the
working directory:

import os
print("Start")
print("working directory:", os.getcwd())
input("   Starter file")

then wrap the open in a try/except block:

try:
Starter = open("HLY-LOG5.txt","w")
except Exception as e:
print("Error: {e}")
input("End")

This should now tell you in which directory the program is actually trying
to create the file and why it didn't work.

hip

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | [email protected] |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: What is the tool used here?

2025-12-07 Thread Em



Footnote:
Fifteen plus Fifteen is thirty.
Sixteen and Sixteen is thirty too.

-Original Message-
From: Thomas Passin  
Sent: Sunday, December 7, 2025 4:31 PM
To: [email protected]
Subject: Re: What is the tool used here?

On 12/7/2025 3:37 PM, Em wrote:
> 
> 
> 
> -Original Message-
> From: Roel Schroeven 
> Sent: Sunday, December 7, 2025 12:29 PM
> To: [email protected]
> Subject: Re: What is the tool used here?
> 
> Op 7/12/2025 om 17:25 schreef Em:
>> I see >, >>, and >>>, attached at the beginning of lines in messages.   I
>> doubt that they are placed manually and wonder how they are placed 
>> automatically. How do I get said program?
> Proper mail clients insert those when replying to messages. Are you using 
> Outlook? I'm not familiar with it, but maybe this can be of help:
> https://support.microsoft.com/en-us/office/reply-with-inline-comments-
> within-the-original-message-text-5bc44105-aeb2-49e2-8239-5aeeff52e5a7
> 
> [SGA] Ok, good guess that I am using Outlook however, I do not seem to be 
> able to enable the > as preface. I can place my initials for now...

The recipient's email client does the marking when it opens a message. 
Normally you don't have to do anything at all. If you try to add your own 
markings, you may mess up the correct nesting of the replies.


[SGA] My initials in the brackets is about the only change I can make. The 
option for ">" is there but not available.



> --
> "The major problem—one of the major problems, for there are several—one of 
> the many major problems with governing people is that of whom you get to do 
> it; or rather of who manages to get people to let them do it to them.
> To summarize: it is a well-known fact that those people who must want to rule 
> people are, ipso facto, those least suited to do it.
> To summarize the summary: anyone who is capable of getting themselves made 
> President should on no account be allowed to do the job."
>   -- Douglas Adams, The Restaurant at the End of the Universe
> 
> 

--
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: A switch somewhere, or bug? CORRECTION

2025-12-07 Thread Em



-Original Message-
From: Roel Schroeven  
Sent: Sunday, December 7, 2025 12:26 PM
To: [email protected]
Subject: Re: A switch somewhere, or bug? CORRECTION

Op 7/12/2025 om 15:46 schreef Thomas Passin:
> On 12/7/2025 7:22 AM, Roel Schroeven wrote:
>> Op 7/12/2025 om 1:54 schreef Thomas Passin:
>>> As I explained in my last post, that's because in Windows 11 when 
>>> double-clicking, the working directory is the system's Windows 
>>> directory, not the one your program is in.
>> Irrespective of anything else that's going on, that's not my 
>> experience. I just tried, and double-clicking a python script makes 
>> the directory that I have open in Explorer the current directory.
>> I've seen the same not just with scripts but also with executables. I 
>> don't think this is the cause.
>
> It *was* the case *on my system* when I tested the program under 
> consideration.  I included the output and it clearly showed that the 
> working directory at launch was C:\WINDOWS\system32.
>
> The situation about file associations in Windows 11 is complicated 
> because there is the new mechanism, and the old one is still there, 
> apparently, and they may not always work the same way.
Indeed, clearly there are differences between different installations.
>
> By the "old" mechanism I mean the way that the associations were set 
> up in the registry by specifying a logical name like Python.file for 
> the .py extension, and having registry keys for the default program to 
> use for Python.file types. You could display (or change, I think, 
> though I never did) these associations from the command line with the 
> programs assoc and ftype. For example, I used to be able to run this:
>
> C:\Users\tom>ftype Python.file
> Python.file="C:\Windows\py.exe" "%L" %*
>
> Now I get this:
>
> C:\Users\Tom>assoc .py
> File association not found for extension .py
>
> C:\Users\Tom>ftype Python.file
> File type 'Python.file' not found or no open command associated with it.
My Windows 11 still shows

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

So yeah, there are differences, and I have to admit I'm not familiar with how 
those things work.
> At any rate, the OP has been making things harder by not following, or 
> not following completely, the simple suggestions that have been made.
> He needs to find out what the working directory is when the program is 
> run by double-clicking, or he has to make his program work no matter 
> what the startup directory is.  Sample code for all that has been 
> posted in this thread.
I completely agree. Yes, it can be frustrating when something that has always 
worked doesn't work anymore. 

But it seems OP prefers to only complain about it instead of trying to find the 
exact cause and/or a solution,  
despite lots of suggestions in this thread.

[SGA]  Sorry if my knowledge of all this is not as vast as yours.  Maybe it is 
only half-vast.
You totally missed the point if you believe that I prefer "to only complain 
about it instead of trying to find the exact cause..."  The majority of what is 
suggested is foreign to me in commands and in system responses.  It is rather 
arrogant to believe that your answer is the one that will totally answer the 
problem. Have you ever indicated that you have the same problem and that your 
suggestion helps?

So far, only one response here indicated that this problem happened on a system 
other than just mine.  Maybe it occurs on all systems.  

P.S.: I am trying to set Outlook to use the ">" indicators but that option is 
faded and not available to enable.
[SGA] 


--
"The major problem—one of the major problems, for there are several—one of the 
many major problems with governing people is that of whom you get to do it; or 
rather of who manages to get people to let them do it to them.
To summarize: it is a well-known fact that those people who must want to rule 
people are, ipso facto, those least suited to do it.
To summarize the summary: anyone who is capable of getting themselves made 
President should on no account be allowed to do the job."
 -- Douglas Adams, The Restaurant at the End of the Universe


-- 
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: What is the tool used here?

2025-12-07 Thread Em



-Original Message-
From: Roel Schroeven  
Sent: Sunday, December 7, 2025 12:29 PM
To: [email protected]
Subject: Re: What is the tool used here?

Op 7/12/2025 om 17:25 schreef Em:
> I see >, >>, and >>>, attached at the beginning of lines in messages.   I
> doubt that they are placed manually and wonder how they are placed 
> automatically. How do I get said program?
Proper mail clients insert those when replying to messages. Are you using 
Outlook? I'm not familiar with it, but maybe this can be of help: 
https://support.microsoft.com/en-us/office/reply-with-inline-comments-within-the-original-message-text-5bc44105-aeb2-49e2-8239-5aeeff52e5a7

[SGA] Ok, good guess that I am using Outlook however, I do not seem to be able 
to enable the > as preface. I can place my initials for now...
--
"The major problem—one of the major problems, for there are several—one of the 
many major problems with governing people is that of whom you get to do it; or 
rather of who manages to get people to let them do it to them.
To summarize: it is a well-known fact that those people who must want to rule 
people are, ipso facto, those least suited to do it.
To summarize the summary: anyone who is capable of getting themselves made 
President should on no account be allowed to do the job."
 -- Douglas Adams, The Restaurant at the End of the Universe


-- 
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


RE: Python

2025-12-17 Thread Em



Then """ and """ are your better friends.
Dan Espen[-] 

It is interesting how the """ has to obey the indention rule.
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

-- 
https://mail.python.org/mailman3//lists/python-list.python.org


BLANK PAGE when i try Filtering Adsense with abpy

2013-12-22 Thread em rexhepi
I know is my fault i'm no good programmer, I'm a begginer that's why i need 
your help.

I have a python 3.3 project to be finished. I did what i could there is not 
much help on google about this topic.

The project is to load a webpage from any website and filter the ads.
I'm using ABPY library to filter, here is the link:
https://github.com/atereshkin/abpy <- needs to be converted in python 3.x it is 
on 2.x
easylist.txt link: https://easylist-downloads.adblockplus.org/easylist.txt


When I use my code it just displays nothing

My code:
#!/usr/local/bin/python3.1

import cgitb;cgitb.enable()

import urllib.request
response = urllib.request.build_opener()
response.addheaders = [('User-agent', 'Mozilla/5.0')]
response = urllib.request.urlopen("www.youtube.com";)

html = response.read()

from abpy import Filter
with open("easylist.txt") as f:
f = Filter(file('easylist.txt'))
f.match(html)


print("Content-type: text/html")
print()
print (html)
-- 
https://mail.python.org/mailman/listinfo/python-list


Help with TypeError: Can't convert 'list' object to str implicitly

2014-02-05 Thread dave em
Hello,

Background.  My 11 y/o son and I have taken on the task to learn python and 
work our way through the http://inventwithpython.com/chapters/ book.
-  We are currently on Chapter 9 and trying to modify the hangman program.

- the first challenge was to modify the word list into a dictionary.  So we 
changed our words variable into a dictionary
--  I believe we did this correctly.

-  But we somehow broke the game.  All of the words are only two letters and 
the program crashes on exit with the following error.

 Traceback (most recent call last):
  File "/media/.../Python/hangman.py", line 155, in 
print('You have run out of guesses! \n After ' + str(len(missedLetters)) + 
' missed guesses and ' + str(len(correctLetters)) + ' correct guesses, the word 
was "' + secretWord + '"')
TypeError: Can't convert 'list' object to str implicitly

-I can't see why this wouldn't work.  By definition isn't this the cast:

1)  len(correctLetters) //returns the lengths of the variable as an int
2)  str(len(correctLetters)) // converts the integer into a string.

Applicable code is here:
 # Check if player has guessed too many times and lost
if len(missedLetters) == len(HANGMANPICS) - 1:
displayBoard(HANGMANPICS, missedLetters, correctLetters, secretWord)
print('You have run out of guesses! \n After ' + 
str(len(missedLetters)) + ' missed guesses and ' + str(len(correctLetters)) + ' 
correct guesses, the word was "' + secretWord + '"')
gameIsDone = True

Any help to get us past this error message is most appreciated.

Thanks in advance,
Dave
-- 
https://mail.python.org/mailman/listinfo/python-list


[Solved]Re: Help with TypeError: Can't convert 'list' object to str implicitly

2014-02-05 Thread dave em
On Wednesday, February 5, 2014 7:21:29 PM UTC-7, dave em wrote:
> Hello,
> 
> 
> 
> Background.  My 11 y/o son and I have taken on the task to learn python and 
> work our way through the http://inventwithpython.com/chapters/ book.
> 
> -  We are currently on Chapter 9 and trying to modify the hangman program.
> 
> 
> 
> - the first challenge was to modify the word list into a dictionary.  So we 
> changed our words variable into a dictionary
> 
> --  I believe we did this correctly.
> 
> 
> 
> -  But we somehow broke the game.  All of the words are only two letters and 
> the program crashes on exit with the following error.
> 
> 
> 
>  Traceback (most recent call last):
> 
>   File "/media/.../Python/hangman.py", line 155, in 
> 
> print('You have run out of guesses! \n After ' + str(len(missedLetters)) 
> + ' missed guesses and ' + str(len(correctLetters)) + ' correct guesses, the 
> word was "' + secretWord + '"')
> 
> TypeError: Can't convert 'list' object to str implicitly
> 
> 
> 
> -I can't see why this wouldn't work.  By definition isn't this the cast:
> 
> 
> 
> 1)  len(correctLetters) //returns the lengths of the variable as an int
> 
> 2)  str(len(correctLetters)) // converts the integer into a string.
> 
> 
> 
> Applicable code is here:
> 
>  # Check if player has guessed too many times and lost
> 
> if len(missedLetters) == len(HANGMANPICS) - 1:
> 
> displayBoard(HANGMANPICS, missedLetters, correctLetters, 
> secretWord)
> 
> print('You have run out of guesses! \n After ' + 
> str(len(missedLetters)) + ' missed guesses and ' + str(len(correctLetters)) + 
> ' correct guesses, the word was "' + secretWord + '"')
> 
> gameIsDone = True
> 
> 
> 
> Any help to get us past this error message is most appreciated.
> 
> 
> 
> Thanks in advance,
> 
> Dave

Fixed the error and am now onto the next issue.

Solution was to return a list (I think) and then break out the components of 
the list and put in the variable.  Here is how we did it:

secretWord = getRandomWord(words)
print('The secretWord is ' + str(secretWord[0]))
print('The secretKey is ' + str(secretWord[1]))
#Change secretWord from a list to a str
secretWord = secretWord[1] 


def getRandomWord(wordDict):
# This function returns a random string from the passed dictionary of lists 
of strings, and the key also.
# First, randomly select a key from the dictionary:
wordKey = random.choice(list(wordDict.keys()))
print('The wordKey is ' + wordKey)
# Second, randomly select a word from the key's list in the dictionary:
wordIndex = random.randint(0, len(wordDict[wordKey]) - 1)
print('The wordIndex is ' + str(wordIndex))
print('The word is ' + wordDict[wordKey][wordIndex])
return [wordDict[wordKey][wordIndex], wordKey]

Cheers,
Dave
-- 
https://mail.python.org/mailman/listinfo/python-list


Help with an 8th grade science project

2014-11-20 Thread dave em
Hello,

I am the adult advisor (aka father) to an 8th grader who is doing a science 
project that will compare / benchmark CPU performance between an AMD 64 Phenom 
II running Ubuntu 14.04 and a Raspberry Pi 700MHz ARM.

Basic procedure:
-  Run a Python script on both computers that that stresses the CPU and measure
--  Time to complete the calculation
-- Max CPU during the calculation
-- We have chosen to do factorials and compare performance by running 
calculations by order of magnitude.  Our hypothesis is that we will begin to 
see a wider performance gap between the two computers as the factorials 
increase in order of magnitude.

Status:
-  We have a working program.  Pseudo code follows:

import linux_metrics
from linux_metrics import cpu_stat
import time

print 'Welcome to the stress test'
number = raw_input("Enter the number to compute the factorial:")

## function to calculate CPU usage percentage
def CPU_Percent():
cpu_pcts = cpu_stat.cpu_percents(.25)
print 'cpu utilization: %.2f%%' % (100 - cpu_pcts['idle'])
write cpu utilization to a csv file with g.write 

## function to compute factorial of a given number
def factorial(n):
num = 1
while n >= 1:
num = num * n
CPU_Percent()  This is the function call irt Q 1 below 
n = n - 1
return num

# Main program
Record start time by using time.time()
Call function to compute the factorial.
Record finish time by using time.time()
write time to compute to a file f.write(totalEndTime - totalStartTime)
print ("Execution time = ", totalEndTime - totalStartTime)


Questions:
1.  In the factorial() function we call the CPU_Percent() function and write 
the CPU utilization value to a file.
-  Is this a correct value or will the CPU utilization below lower because the 
factorial() function made its calculation and is now just checking the CPU 
utilization?
-  If we are not getting the true max CPU utilization, can someone offer a 
design change to accomplish this?

2.  What unit does time.time() use?  An example for calculating the factorial 
of 10 is our program gives:
  Execution time = ', 1.5703258514404297  I presume this is telling us it took 
1.57 seconds to complete the calculation?

Thanks in advance for any help / suggestions.

Best regards,
Dave
-- 
https://mail.python.org/mailman/listinfo/python-list


Explanation of list reference

2014-02-14 Thread dave em
Hello,

Background:  My twelve y/o son and I are still working our way through Invent 
Your Own Computer Games with Python, 2nd Edition.
(We finished the Khan Academy Javascript Tutorials is the extent of our 
experience)

He is asking a question I am having trouble answering which is how a variable 
containing a value differs from a variable containing a list or more 
specifically a list reference.

I tried the to explain as best I can remember is that a variable is assigned to 
a specific memory location with a value inside of it.  Therefore, the variable 
is kind of self contained and if you change the variable, you change the value 
in that specific memory location.

However, when a variable contains a list reference, the memory location of the 
variable points to a separate memory location that stores the list.  It is also 
possible to have multiple variable that point to the memory location of the 
list reference.  And all of those variable can act upon the list reference.

Question:  Is my explanation correct?  If not please set me straight :)

And does anyone have an easier to digest explanation?

Thanks in advance,
Dave
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of list reference

2014-02-14 Thread dave em
On Friday, February 14, 2014 11:26:13 AM UTC-7, Jussi Piitulainen wrote:
> dave em writes:
> 
> 
> 
> > He is asking a question I am having trouble answering which is how a
> 
> > variable containing a value differs from a variable containing a
> 
> > list or more specifically a list reference.
> 
> 
> 
> My quite serious answer is: not at all. In particular, a list is a
> 
> value.
> 
> 
> 
> All those pointers to references to locations are implementation
> 
> details. The user of the language needs to understand that an object
> 
> keeps its identity when it's passed around: passed as an argument,
> 
> returned by a function, stored in whatever location, retrieved from
> 
> whatever location.

Jessi,

Thanks for your quick response.  I'm still not sure we understand.  The code 
below illustrates the concept we are trying to understand.

Case 1: Example of variable with a specific value from P 170 of IYOCGWP

>>> spam = 42
>>> cheese = spam
>>> spam = 100
>>> spam
100
>>> cheese
42

Case 2: Example of variable with a list reference from p 170

>>> spam = [0, 1, 2, 3, 4, 5]
>>> cheese = spam
>>> cheese[1] = 'Hello!'
>>> spam
[0, 'Hello!', 2, 3, 4, 5]
>>> cheese
[0, 'Hello!', 2, 3, 4, 5]

What I am trying to explain is this, why in case 1 when acting on spam 
(changing the value from 42 to 100) only affects spam and not cheese.  
Meanwhile, in case two acting on cheese also affects spam.


Thanks and v/r,
Dave
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explanation of list reference

2014-02-14 Thread dave em
All,

Thanks for the excellent explanations and for sharing your knowledge.  I 
definitely have a better understanding than I did this morning.

Best regards,
Dave
-- 
https://mail.python.org/mailman/listinfo/python-list


converting strings to hex

2014-04-03 Thread dave em
Hello,

I am taking a cryptography class and am having a tough time with an assignment 
similar to this.

Given plain text message 1 and cipher 1 compute cipher 2 for message 2

Work flow will be:
- figure out the key
- use key to compute c2

So this is what I have so far and am getting nowhere fast.  I could use a 
little help on this one.

So my first step is to compute the key.  I suspect my error below is because c1 
is a float and m1 is a string but I don't know how to turn the string into a 
float.


  Python 2.7###

m1text="my test message"
print( m1text + ' in hex is ')
print m1text.encode("hex")
m1 = m1text.encode("hex")
c1=0x6c73d5240a948c86981bc294814d 

k=m1^c1
print( 'the key = ' )
print hex(k)

This code yields the following:

my test message in hex is 
6d792074657374206d657373616765
Traceback (most recent call last):
  File "/media/.../Crypto/Attackv2.py", line 10, in 
k=m1^c1
TypeError: unsupported operand type(s) for ^: 'str' and 'long'

Any help is most appreciated.

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


Re: converting strings to hex

2014-04-03 Thread dave em
On Thursday, April 3, 2014 8:31:42 PM UTC-6, Tim Chase wrote:
> On 2014-04-03 19:10, dave em wrote:
> 
> > So my first step is to compute the key.  I suspect my error below
> 
> > is because c1 is a float and m1 is a string but I don't know how to
> 
> > turn the string into a float.
> 
> 
> 
> For the record, "c1" in your example should be an integer/long
> 
> 
> 
> It sounds like you want the optional parameter to int() so you'd do
> 
> 
> 
> >>> hex_string = "My text message".encode("hex")
> 
> >>> hex_string
> 
> '4d792074657874206d657373616765'
> 
> >>> m1 = int(hex_string, 16)  # magic happens here
> 
> >>> m1
> 
> 402263600993355509170946582822086501L
> 
> >>> c1=0x6c73d5240a948c86981bc294814d 
> 
> >>> c1
> 
> 2199677439761906166135512011931981L
> 
> >>> k = m1 ^ c1
> 
> >>> k
> 
> 400239414552556350237329405469124136L
> 
> >>> hex(k) # as a string
> 
> '0x4d1553a14172e0acebfd68b1f5e628L'
> 
> 
> 
> 
> 
> -tkc

Thanks, got it.  Sometimes the simple things can be difficult.

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


Re: converting strings to hex

2014-04-03 Thread dave em

> You haven't seen nothing yet, wait till M.L. catches you on the flip 
> 
> side for using gg.   {running for cover}


Who is ML?
-- 
https://mail.python.org/mailman/listinfo/python-list