Re: LRU cache

2023-02-22 Thread Rob Cliffe via Python-list
On 18/02/2023 17:19, Albert-Jan Roskam wrote: On Feb 18, 2023 17:28, Rob Cliffe via Python-list wrote: On 18/02/2023 15:29, Thomas Passin wrote: > On 2/18/2023 5:38 AM, Albert-Jan Roskam wrote: >>     I sometimes use this trick, which I learnt from a book by Martelli.

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-22 Thread Greg Ewing via Python-list
On 23/02/23 9:37 am, Hen Hanna wrote: for the first several weeks... whenever i used Python... all i could think ofwas this is really Lisp (inside) with a thin veil of Java/Pascal syntax.. - that everything is first

Re: semi colonic

2023-02-22 Thread Greg Ewing via Python-list
On 23/02/23 1:58 pm, avi.e.gr...@gmail.com wrote: Would anything serious break if it was deprecated for use as a statement terminator? Well, it would break all the code of people who like to write code that way. They might get a bit miffed if we decide that their code is not serious. :-) On

Re: Introspecting the variable bound to a function argument

2023-02-22 Thread Greg Ewing via Python-list
On 23/02/23 9:12 am, Hen Hanna wrote: On Wednesday, February 22, 2023 at 2:32:57 AM UTC-8, Anton Shepelev wrote: def f(a): print(black_magic(a))# or black_magic('a') f(v1)# prints: v1 f(v2)# prints: v2 the

Re: semi colonic

2023-02-22 Thread Thomas Passin
On 2/22/2023 10:42 PM, avi.e.gr...@gmail.com wrote: That seems like a reasonable if limited use of a semi-colon, Thomas. Of course, most shells will allow a multi-line argument too like some AWK scripts I have written with a quote on the first line followed by multiple lines of properly

RE: semi colonic

2023-02-22 Thread avi.e.gross
That seems like a reasonable if limited use of a semi-colon, Thomas. Of course, most shells will allow a multi-line argument too like some AWK scripts I have written with a quote on the first line followed by multiple lines of properly formatted code and a closing quote. Python though can get

Re: semi colonic

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 6:21:13 PM UTC-8, Rob Cliffe wrote: > On 23/02/2023 02:04, Thomas Passin wrote: > > On 2/22/2023 7:58 PM, avi.e...@gmail.com wrote: > >> > >> > >> So can anyone point to places in Python where a semicolon is part of > >> a best > >> or even good way to do

Re: Add angle brackets for required args in argparse

2023-02-22 Thread scruel tao
Thank you for your workarounds, Mark Bourne. `metavar` argument should be sufficient for infrequent use scenarios, and I will consider to use the custom help formatter if necessary. >>> That's a bit closer to what you asked for, since the required argument >>> shown in the error message doesn't

Re: semi colonic

2023-02-22 Thread Rob Cliffe via Python-list
On 23/02/2023 02:04, Thomas Passin wrote: On 2/22/2023 7:58 PM, avi.e.gr...@gmail.com wrote: So can anyone point to places in Python where a semicolon is part of a best or even good way to do anything?  I use the semicolon (once in a while) is for quick debugging.  I might add as line

Re: semi colonic

2023-02-22 Thread Thomas Passin
On 2/22/2023 7:58 PM, avi.e.gr...@gmail.com wrote: Thomas, This is one of many little twists I see between languages where one feature impacts use or even the need for another feature. So can anyone point to places in Python where a semicolon is part of a best or even good way to do anything?

Re: Python + Vim editor

2023-02-22 Thread Cameron Simpson
On 21Feb2023 18:00, Hen Hanna wrote: what editor do you (all) use to write Python code? (i use Vim) vim -- https://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 3:46:21 PM UTC-8, Hen Hanna wrote: > On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote: > > > py bug.py > > Traceback (most recent call last): > > File "C:\Usenet\bug.py", line 5, in > > print( a + 12 ) > > TypeError: can only

semi colonic

2023-02-22 Thread avi.e.gross
Thomas, This is one of many little twists I see between languages where one feature impacts use or even the need for another feature. So can anyone point to places in Python where a semicolon is part of a best or even good way to do anything? Some older languages had simple parsers/compilers

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Thomas Passin
On 2/22/2023 6:46 PM, Hen Hanna wrote: On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote: py bug.py Traceback (most recent call last): File "C:\Usenet\bug.py", line 5, in print( a + 12 ) TypeError: can only concatenate str (not "int") to str Why doesn't Python (error

Re: Introspecting the variable bound to a function argument

2023-02-22 Thread Thomas Passin
On 2/22/2023 3:12 PM, Hen Hanna wrote: On Wednesday, February 22, 2023 at 2:32:57 AM UTC-8, Anton Shepelev wrote: Hello, all. Does Python have an instrospection facility that can determine to which outer variable a function argument is bound, e.g.: v1 = 5; v2 = 5; do some Python coders

Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote: > > py bug.py > Traceback (most recent call last): > File "C:\Usenet\bug.py", line 5, in > print( a + 12 ) > TypeError: can only concatenate str (not "int") to str > > > Why doesn't Python (error msg) do the obvious

Re: Line continuation and comments

2023-02-22 Thread Cameron Simpson
On 22Feb2023 11:27, Thomas Passin wrote: On 2/22/2023 10:02 AM, Weatherby,Gerard wrote: That’s a neat tip. End of line comments work, too x = (3 > 4 #never and 7 == 7 # hopefully or datetime.datetime.now().day > 15 # sometimes ) print(x) I find myself doing this more and

Re: Python + Vim editor

2023-02-22 Thread Mats Wichmann
On 2/22/23 11:16, Tramiv wrote: On 2023-02-22, Hen Hanna wrote: what editor do you (all) use to write Python code? (i use Vim) For short editin I also use Vim and Pycharm IDE for bigger projects. The community has submitted some answers to that question here (two lists, some entrants

RE: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread avi.e.gross
Hen or Hanna, You keep asking WHY which may be reasonable but hard or irrelevant in many cases. I find the traceback perfectly informative. It says you asked it to print NOT just "a" but "a + 12" and the error is coming not from PRINT but from trying to invoke addition between two objects that

it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-22 Thread Hen Hanna
it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and i'd get [Segmentation Fault] (core dumped) [Bus Error] (core dumped) [access violation] (core dumped)

Re: is [comprehension] the right word???

2023-02-22 Thread Hen Hanna
On Monday, February 20, 2023 at 5:45:39 PM UTC-8, Paul Rubin wrote: > Hen Hanna writes: > > is [comprehension] the right word??? > Yes, it comes from math, particularly set theory. An expression like > > { n | n:integer, n mod 2 = 0 } > > is called a set comprehension, and then one there

Re: Introspecting the variable bound to a function argument

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 2:32:57 AM UTC-8, Anton Shepelev wrote: > Hello, all. > > Does Python have an instrospection facility that can > determine to which outer variable a function argument is > bound, e.g.: > > v1 = 5; > v2 = 5; do some Python coders like to end lines with

Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Hen Hanna
> py bug.py Traceback (most recent call last): File "C:\Usenet\bug.py", line 5, in print( a + 12 ) TypeError: can only concatenate str (not "int") to str Why doesn't Python (error msg) do the obvious thing and tell me

Re: Creating logs with Python

2023-02-22 Thread Dave (NK7Z)
Thank you Gerard! I am working on a project and needed that... :) 73, and thanks, Dave (NK7Z) https://www.nk7z.net ARRL Volunteer Examiner ARRL Technical Specialist, RFI ARRL Asst. Director, NW Division, Technical Resources On 2/22/23 07:03, Weatherby,Gerard wrote:

Re: Python + Vim editor

2023-02-22 Thread Thomas Passin
On 2/22/2023 1:45 PM, orzodk wrote: Thomas Passin writes: On 2/22/2023 12:00 AM, orzodk wrote: Thomas Passin writes: On 2/21/2023 9:00 PM, Hen Hanna wrote: what editor do you (all) use to write Python code? (i use Vim) I usually use the Leo-editor

Re: Python + Vim editor

2023-02-22 Thread orzodk
Thomas Passin writes: > On 2/22/2023 12:00 AM, orzodk wrote: >> Thomas Passin writes: >> >>> On 2/21/2023 9:00 PM, Hen Hanna wrote: what editor do you (all) use to write Python code? (i use Vim) >>> >>> I usually use the Leo-editor (https://github.com/leo-editor/leo-editor >>> or PyPi).

Re: Python + Vim editor

2023-02-22 Thread Tramiv
On 2023-02-22, Hen Hanna wrote: > > what editor do you (all) use to write Python code? (i use Vim) > For short editin I also use Vim and Pycharm IDE for bigger projects. -- https://mail.python.org/mailman/listinfo/python-list

Re: Introspecting the variable bound to a function argument

2023-02-22 Thread Barry
please do not use an email address on a public list that cannot be replied to. > On 22 Feb 2023, at 14:43, Anton Shepelev wrote: > > Hello, all. > > Does Python have an instrospection facility that can > determine to which outer variable a function argument is > bound, e.g.: There is no

Re: Line continuation and comments

2023-02-22 Thread Thomas Passin
On 2/22/2023 10:02 AM, Weatherby,Gerard wrote: That’s a neat tip. End of line comments work, too x = (3 > 4 #never and 7 == 7 # hopefully or datetime.datetime.now().day > 15 # sometimes ) print(x) I find myself doing this more and more often. It can also help to make the

Re: Line continuation and comments

2023-02-22 Thread Weatherby,Gerard
That’s a neat tip. End of line comments work, too x = (3 > 4 #never and 7 == 7 # hopefully or datetime.datetime.now().day > 15 # sometimes ) print(x) From: Python-list on behalf of Edmondo Giovannozzi Date: Wednesday, February 22, 2023 at 9:40 AM To: python-list@python.org

Re: Line continuation and comments

2023-02-22 Thread Paul Bryan
Adding to this, there should be no reason now in recent versions of Python to ever use line continuation. Black goes so far as to state "backslashes are bad and should never be used":

Re: Creating logs with Python

2023-02-22 Thread Weatherby,Gerard
https://docs.python.org/3/howto/logging.html From: Python-list on behalf of Bibi Date: Wednesday, February 22, 2023 at 9:44 AM To: python-list@python.org Subject: Creating logs with Python *** Attention: This is an external email. Use caution responding, opening attachments or clicking on

Creating logs with Python

2023-02-22 Thread Bibi
Hello I want to store and make available as part of my project, logs, for access to data. Do you have any proposals? Kind regards -- https://mail.python.org/mailman/listinfo/python-list

Introspecting the variable bound to a function argument

2023-02-22 Thread Anton Shepelev
Hello, all. Does Python have an instrospection facility that can determine to which outer variable a function argument is bound, e.g.: v1 = 5; v2 = 5; def f(a): print(black_magic(a)) # or black_magic('a') f(v1) # prints: v1 f(v2) # prints: v2 -- () ascii ribbon

Re: Line continuation and comments

2023-02-22 Thread Edmondo Giovannozzi
Il giorno mercoledì 22 febbraio 2023 alle 09:50:14 UTC+1 Robert Latest ha scritto: > I found myself building a complicated logical condition with many ands and > ors > which I made more manageable by putting the various terms on individual lines > and breaking them with the "\" line

Line continuation and comments

2023-02-22 Thread Robert Latest via Python-list
I found myself building a complicated logical condition with many ands and ors which I made more manageable by putting the various terms on individual lines and breaking them with the "\" line continuation character. In this context it would have been nice to be able to add comments to lines terms

__getattr__ is much slower in Python3.11

2023-02-22 Thread 王翔
hello everyone: I upgrade my project from Py3.10.4 to Py3.11.1 recently and I noticed Py3.11.1 is faster than Py3.10.4 except for some testcase, like __getattr__. This is my test code in python discussion: https://discuss.python.org/t/getattr-is-much-slower-in-python3-11/24028 But no one knows