Re: Best use of "open" context manager

2024-07-06 Thread Richard Damon via Python-list
My thoughts is that if the "many lines of code" puts the except to far from the try, then perhaps it would have made sense to factor out some part there into a function. Perhaps like: try:    with open(FileName) as f:   for ln in f{ process(ln) except FileNotFoundError:   

Re: UTF_16 question

2024-04-29 Thread Richard Damon via Python-list
> On Apr 29, 2024, at 12:23 PM, jak via Python-list > wrote: > > Hi everyone, > one thing that I do not understand is happening to me: I have some text > files with different characteristics, among these there are that they > have an UTF_32_le coding, utf_32be, utf_16_le, utf_16_be all of them

Re: Python misbehavior

2024-02-08 Thread Richard Damon via Python-list
On 2/6/24 10:46 PM, Jim via Python-list wrote: Friends, Please forgive me if this is not the proper forum for dealing with an issue of mine, but I am at a loss in finding a fix for a python problem in the program ClipGrab. The program allows one to download videos or audios from YouTube and

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

2023-12-28 Thread Richard Damon via Python-list
On 12/28/2023 12:20 AM EST rbowman via Python-list <[1]python-list@python.org> wrote: On Wed, 27 Dec 2023 03:53:42 -0600, Greg Walters wrote: The biggest caveat is that the shared variable MUST exist before it can be examined or used (not surprising).

Context without manager

2023-11-27 Thread Richard Damon via Python-list
Read the Fine context manager documentation. What “with with_expression as var” does is effectively: ob = with_expression var = ob.__enter__() And then at the end of the with, does a ob.__exit__() (With some parameters to __exit__, that could just be None, None, None for the simplest case).

Re: Context without manager

2023-11-27 Thread Richard Damon via Python-list
Read the Fine context manager documentation. What “with with_expression as var” does is effectively: ob = with_expression var = ob.__enter__() And then at the end of the with, does a ob.__exit__() (With some parameters to __exit__, that could just be None, None, None for the simplest case).

Re: type annotation vs working code

2023-10-01 Thread Richard Damon via Python-list
My view of the issue is that the "trick" of "evaluating" a name to see if the object has been initialized is just a tad on the "tricky" side, and the annotation/value is really incorrect. The name at the point you are annotating it, isn't really a "bool" because a bool will always have either

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Richard Damon via Python-list
> On Aug 17, 2023, at 10:02 AM, c.buhtz--- via Python-list > wrote: > > X-Post: https://stackoverflow.com/q/76913082/4865723 > > I want to display one string in its original source (untranslated) version > and in its translated version site by site without duplicating the string in > the

Re: Multiple inheritance and a broken super() chain

2023-07-03 Thread Richard Damon via Python-list
On 7/3/23 1:38 PM, Peter Slížik via Python-list wrote: Hello. The legacy code I'm working with uses a classic diamond inheritance. Let me call the classes *Top*, *Left*, *Right*, and *Bottom*. This is a trivial textbook example. The classes were written in the pre-super() era, so all of them