Re: Best use of "open" context manager

2024-07-06 Thread Dan Sommers via Python-list
On 2024-07-06 at 11:49:06 +0100, Rob Cliffe via Python-list wrote: > Is there a better / more Pythonic solution? https://docs.python.org/3/library/fileinput.html At least this attempts to abstract the problem of iterating over a file (or multiple files) into a library routine. I've used it a

Re: Any marginally usable programming language approaches an ill defined barely usable re-implementation of half of Common-Lisp

2024-05-29 Thread Dan Sommers via Python-list
On 2024-05-29 at 11:39:14 -0700, HenHanna via Python-list wrote: > On 5/27/2024 1:59 PM, 2qdxy4rzwzuui...@potatochowder.com wrote: > > https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule [...] > Are the Rules 1--9 by Greenspun good too? I don't know; let me look it up. Oh, there it

Formatted Output and Argument Parsing (was: Re: Flubbed it in the second interation through the string: range error... HOW?)

2024-05-29 Thread Dan Sommers via Python-list
On 2024-05-29 at 17:14:51 +1000, Chris Angelico via Python-list wrote: > I wouldn't replace str.format() everywhere, nor would I replace > percent encoding everywhere - but in this case, I think Thomas is > correct. Not because it's 2024 (f-strings were brought in back in > 2015, so they're

Re: Any marginally usable programming language approaches an ill defined barely usable re-implementation of half of Common-Lisp

2024-05-27 Thread Dan Sommers via Python-list
On 2024-05-27 at 12:37:01 -0700, HenHanna via Python-list wrote: > > On 5/27/2024 7:18 AM, Cor wrote: > > Some entity, AKA "B. Pym" , > > wrote this mindboggling stuff: > > (selectively-snipped-or-not-p) > > > > > On 12/16/2023, c...@clsnet.nl wrote: > > > > > > > Any marginally usable

Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread Dan Sommers via Python-list
On 2024-05-19 at 18:13:23 +, Gilmeh Serda via Python-list wrote: > Was there a reason they chose the name Pip? Package Installer for Python https://pip.pypa.io/en/stable/index.html -- https://mail.python.org/mailman/listinfo/python-list

Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread Dan Sommers via Python-list
On 2024-05-19 at 18:13:23 +, Gilmeh Serda via Python-list wrote: > Was there a reason they chose the name Pip? Package Installer for Python https://pip.pypa.io/en/stable/index.html Every time I see PIP, I think Peripheral Interchange Program, but I'm old. --

Re: how to discover what values produced an exception?

2024-05-04 Thread Dan Sommers via Python-list
On 2024-05-03 at 10:56:39 -0300, Johanne Fairchild via Python-list wrote: > How to discover what values produced an exception? Or perhaps---why > doesn't the Python traceback show the values involved in the TypeError? > For instance: > >

Re: Configuring an object via a dictionary

2024-03-20 Thread Dan Sommers via Python-list
On 2024-03-20 at 09:49:54 +0100, Roel Schroeven via Python-list wrote: > You haven't only checked for None! You have rejected *every* falsish value, > even though they may very well be acceptable values. OTOH, only you can answer these questions about your situations. Every application, every

Re: Configuring an object via a dictionary

2024-03-15 Thread Dan Sommers via Python-list
On 2024-03-15 at 15:48:17 -0400, Thomas Passin via Python-list wrote: > [...] And I suppose there is always the possibility that sometime in > the future an "or" clause like that will be changed to return a > Boolean, which one would expect anyway. Not only is the current value is way more

Re: Extract lines from file, add to new files

2024-01-13 Thread Dan Sommers via Python-list
On 2024-01-13 at 11:34:29 +0100, Left Right wrote: > > The Python term, at least colloquially, is "tuple unpacking." That quote is from me. Please do preserve attributions. > Well, why use colloquialism if there's a language specification? Also, > there weren't any tuples used in my example,

Re: Extract lines from file, add to new files

2024-01-12 Thread Dan Sommers via Python-list
On 2024-01-13 at 02:02:39 +0100, Left Right via Python-list wrote: > Actually, after some Web search. I think, based on this: > https://docs.python.org/3/reference/simple_stmts.html#grammar-token-python-grammar-augtarget > that in Python you call this "augmented assignment target". The term >

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

2023-12-06 Thread Dan Sommers via Python-list
On 2023-12-06 at 09:32:02 +, Chris Green via Python-list wrote: > Thomas Passin wrote: [...] > > Just go with an .ini file. Simple, well-supported by the standard > > library. And it gives you key/value pairs. > > > My requirement is *slightly* more complex than just key value pairs, >

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Dan Sommers via Python-list
On 2023-11-29 at 21:44:01 -0300, Julieta Shem via Python-list wrote: > How would you write this procedure? > > --8<---cut here---start->8--- > def powers_of_2_in(n): > s = 0 > while "I still find factors of 2 in n...": > q, r = divmod(n, 2) > if r

Re: Beep on WIndows 11

2023-11-12 Thread Dan Sommers via Python-list
On 2023-11-11 at 23:44:19 +, Y Y via Python-list wrote: > I am curious and humble to ask: What is the purpose of a BEEP? It's a simple way for a terminal-based program to alert (hence '\a') a user or an operator that their attention is requested or required. See also

Re: Why doc call `__init__` as a method rather than function?

2023-09-15 Thread Dan Sommers via Python-list
On 2023-09-15 at 10:49:10 +, scruel tao via Python-list wrote: > ```python > >>> class A: > ... def __init__(self): > ... pass > ... > >>> A.__init__ > > >>> a = A() > >>> a.__init__ > > > ``` > > On many books and even the official documents, it seems that many authors > prefer to

Re: ANN: A new version (0.5.1) of python-gnupg has been released.

2023-07-22 Thread Dan Sommers via Python-list
On 2023-07-22 at 11:04:35 +, Vinay Sajip via Python-list wrote: > What Changed? > = What changed, indeed. Maybe I'm old, and curmudgeonly, but it would be nice if the body of these annoucement emails (not just this one) contained the name of the program and a one-line summary