Re: What can I do about this?

2022-08-29 Thread Mark Bourne
gene heskett wrote: On 8/29/22 12:50, Mark Bourne wrote: Roel Schroeven wrote: Op 29/08/2022 om 2:55 schreef gene heskett: On 8/28/22 19:39, Peter J. Holzer wrote: On 2022-08-28 18:40:17 -0400, gene heskett wrote: Persuant to my claim the py3.10 is busted, here is a sample. This is me

Re: How to make a variable's late binding crosses the module boundary?

2022-08-29 Thread Mark Bourne
Jach Feng wrote: Chris Angelico 在 2022年8月29日 星期一下午1:58:58 [UTC+8] 的信中寫道: On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: Richard Damon 在 2022年8月29日 星期一上午10:47:08 [UTC+8] 的信中寫道: On 8/27/22 7:42 AM, Mark Bourne wrote: Jach Feng wrote: I have two files: test.py and test2.py --test.py-- x = 2

Re: What can I do about this?

2022-08-29 Thread Mark Bourne
Roel Schroeven wrote: Op 29/08/2022 om 2:55 schreef gene heskett: On 8/28/22 19:39, Peter J. Holzer wrote: On 2022-08-28 18:40:17 -0400, gene heskett wrote: Persuant to my claim the py3.10 is busted, here is a sample. This is me, trying to make pronterface, inside a venv: When the package

Re: How to make a variable's late binding crosses the module boundary?

2022-08-31 Thread Mark Bourne
Jach Feng wrote: Mark Bourne 在 2022年8月29日 星期一下午6:40:59 [UTC+8] 的信中寫道: Jach Feng wrote: Chris Angelico 在 2022年8月29日 星期一下午1:58:58 [UTC+8] 的信中寫道: On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: Richard Damon 在 2022年8月29日 星期一上午10:47:08 [UTC+8] 的信中寫道: On 8/27/22 7:42 AM, Mark Bourne wrote

Re: How to make a variable's late binding crosses the module boundary?

2022-08-28 Thread Mark Bourne
Jach Feng wrote: I have two files: test.py and test2.py --test.py-- x = 2 def foo(): print(x) foo() x = 3 foo() --test2.py-- from test import * x = 4 foo() - Run test.py under Winows8.1, I get the expected result: e:\MyDocument>py test.py 2 3 But when run test2.py, the result is not

Re: How make your module substitute a python stdlib module.

2022-12-27 Thread Mark Bourne
Antoon Pardon wrote: Op 27/12/2022 om 11:37 schreef Chris Angelico: On Tue, 27 Dec 2022 at 21:29, Antoon Pardon wrote: OK, I am writing an alternative for the threading module. What I would like to know is how I can get some library modules call my alternative instead of the threading

Re: How to enter escape character in a positional string argument from the command line?

2022-12-19 Thread Mark Bourne
Jach Feng wrote: I have a script using the argparse module. I want to enter the string "step\x0A" as one of its positional arguments. I expect this string has a length of 5, but it gives 8. Obviously the escape character didn't function correctly. How to do it? That depends on the

Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-29 Thread Mark Bourne
Jach Feng wrote: Thank you for detail explanation of the role the shell is involved in this problem. I'm very appreciated! It seems that a CLI app may become very complex when dealing with different kind of shell, and may not be possible to solve its problem. But the good thing in my app is

Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-29 Thread Mark Bourne
Jach Feng wrote: Jach Feng 在 2023年1月22日 星期日上午11:11:22 [UTC+8] 的信中寫道: Fail on command line, e:\Works\Python>py infix2postfix.py "-4^2+5.3*abs(-2-1)/2" usage: infix2postfix.py [-h] [infix] infix2postfix.py: error: unrecognized arguments: -4^2+5.3*abs(-2-1)/2 Also fail in REPL,

Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-28 Thread Mark Bourne
Jach Feng wrote: Jach Feng 在 2023年1月22日 星期日上午11:11:22 [UTC+8] 的信中寫道: Fail on command line, e:\Works\Python>py infix2postfix.py "-4^2+5.3*abs(-2-1)/2" usage: infix2postfix.py [-h] [infix] infix2postfix.py: error: unrecognized arguments: -4^2+5.3*abs(-2-1)/2 Also fail in REPL,

Re: evaluation question

2023-01-28 Thread Mark Bourne
mutt...@dastardlyhq.com wrote: On Sat, 28 Jan 2023 14:22:01 +1300 dn wrote: Do you know about the Python REPL? Haven't learnt the acronyms yet. REPL stands for "Read Evaluate Print Loop". It basically refers to the interactive interpreter, which reads input you type, evaluates it,

Re: bool and int

2023-01-27 Thread Mark Bourne
avi.e.gr...@gmail.com wrote: ... Interestingly, I wonder if anyone has designed an alternate object type that can be used mostly in place of Booleans but which imposes changes and restrictions so trying to add a Boolean to an integer, or vice versa, results in an error. Python is flexible enough

Re: To clarify how Python handles two equal objects

2023-01-15 Thread Mark Bourne
Jen Kris wrote: Avi, Your comments go farther afield than my original question, but you made some interesting additional points.  For example, I sometimes work with the C API and sys.getrefcount may be helpful in deciding when to INCREF and DECREF.  But that’s another issue. The situation I

Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-22 Thread Mark Bourne
Jach Feng wrote: Fail on command line, e:\Works\Python>py infix2postfix.py "-4^2+5.3*abs(-2-1)/2" usage: infix2postfix.py [-h] [infix] infix2postfix.py: error: unrecognized arguments: -4^2+5.3*abs(-2-1)/2 Also fail in REPL, e:\Works\Python>py Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021,

Re: Add angle brackets for required args in argparse

2023-02-20 Thread Mark Bourne
scruel tao wrote: If we have the following code: ``` parser = argparse.ArgumentParser(description="test") parser.add_argument('path') ``` Run it without args, will get error message: ``` usage: test.py [-h] path test.py: error: the following arguments are required: path ``` However, I hope the

Re: Line continuation and comments

2023-02-24 Thread Mark Bourne
Personally, I don't particularly like the way you have to put multiline strings on the far left (rather than aligned with the rest of the scope) to avoid getting spaces at the beginning of each line. I find it makes it more difficult to see where the scope of the class/method/etc. actually

Re: Question regarding unexpected behavior in using __enter__ method

2023-04-26 Thread Mark Bourne
Lorenzo Catoni wrote: Dear Python Mailing List members, I am writing to seek your assistance in understanding an unexpected behavior that I encountered while using the __enter__ method. I have provided a code snippet below to illustrate the problem: ``` class X: ... __enter__ = int ...

Re: Pycharm IDE

2023-04-19 Thread Mark Bourne
Thomas Passin wrote: On 4/19/2023 1:27 AM, Kevin M. Wilson via Python-list wrote: Ok, I got rid of the "print (f'"I am thinking of a number between 1 to {LIMIT}\n")"print ("I am thinking of a number between 1 to {LIMIT}\n"), I think you misunderstand several things at the same time here. 1.

Re: Windows installer from python source code without access to source code

2023-04-07 Thread Mark Bourne
MRAB wrote: On 2023-04-06 23:14, Jim Schwartz wrote:     Could someone please help Carlos?  I’m not sure how to answer his     question     Sent from my iPhone   On Apr 6, 2023, at 3:53 PM, Carlos Fulqueris wrote:      Hello Jim,   How can I unsubscribe to this email

Re: ChatGPT Generated news poster code

2023-02-13 Thread Mark Bourne
Mats Wichmann wrote: Meanwhile, I'm still wondering why I need a program to "chat" to the GUID Partition Table Perhaps to keep on good terms with it so that it doesn't run away and hide? I had to go looking for the GPT on one of my disks after it went AWOL a couple of years ago. Eventually

Re: evaluation question

2023-01-31 Thread Mark Bourne
Greg Ewing wrote: On 30/01/23 10:41 pm, mutt...@dastardlyhq.com wrote: What was the point of the upheaval of converting the print command in python 2 into a function in python 3 if as a function print() doesn't return anything useful? It was made a function because there's no good reason

Re: A Function's name during its definition

2023-02-07 Thread Mark Bourne
Stefan Ram wrote: When one defines a function, sometimes its name is only half-existent. One can implicitly evaluate the name of the function: main.py def g(): def f(): print( f ) f() g() output .f at ... , but one gets an error when one tries to

Re: A Function's name during its definition

2023-02-07 Thread Mark Bourne
Stefan Ram wrote: Mark Bourne writes: In the second case, eval() only gets the globals and immediate locals, Yes, I think you are right. Curiously, the following program would mislead one to thing that eval /does/ see the intermediate names: main.py def f(): x = 22 def g

Re: evaluation question

2023-02-02 Thread Mark Bourne
mutt...@dastardlyhq.com wrote: On Wed, 1 Feb 2023 18:28:04 +0100 "Peter J. Holzer" wrote: --b2nljkb3mdefsdhx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2023-02-01 09:00:39 -, mutt...@dastardlyhq.com wrote: Its not

Re: f-string syntax deficiency?

2023-06-06 Thread Mark Bourne via Python-list
Roel Schroeven wrote: Op 6/06/2023 om 16:08 schreef Chris Angelico: On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote: > > The following f-string does not parse and gives syntax error on 3.11.3: > > f'thruput/{"user" if opt.return else "cell"} vs. elevation\n' > > However this expression, which

Attaching a mock function to another mock breaks reset_mock()

2023-06-19 Thread Mark Bourne via Python-list
I've came across an issue with attaching a mock function to another mock object. It looks like this might be a bug in unittest.mock, but it's possible I'm misunderstanding or doing something wrong. I'm currently using Python 3.8.10, which is the default installed on Ubuntu 20.04. I don't

Re: Popping key causes dict derived from object to revert to object

2024-03-22 Thread Mark Bourne via Python-list
Loris Bennett wrote: Hi, I am using SQLAlchemy to extract some rows from a table of 'events'. From the call to the DB I get a list of objects of the type sqlalchemy.orm.state.InstanceState I would like to print these rows to the terminal using the 'tabulate' package, the documentation for

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Mark Bourne via Python-list
Thomas Nyberg wrote: Hi, Yeah so flask does support async (when installed with `pip3 install flask[async]), but you are making a good point that flask in this case is a distraction. Here's an example using just the standard library that exhibits the same issue: `app.py` ``` import asyncio

Re: A missing iterator on itertools module?

2024-04-01 Thread Mark Bourne via Python-list
Stefan Ram wrote: ast wrote or quoted: Why did you renamed itertools as _itertools ? Assume I have a module A.py: import math def f(): pass . Assume I have an additional module B.py: import A . Now, when I'm editing "B.py" in IDLE and type "A.", IIRC IDLE will offer me two

Re: A technique from a chatbot

2024-04-05 Thread Mark Bourne via Python-list
Stefan Ram wrote: Mark Bourne wrote or quoted: I don't think there's a tuple being created. If you mean: ( word for word in list_ if word[ 0 ]== 'e' ) ...that's not creating a tuple. It's a generator expression, which generates the next value each time it's called for. If you only ever

Re: A technique from a chatbot

2024-04-05 Thread Mark Bourne via Python-list
e, imagine doing the search in parallel and as sone as it is found anywhere, ... -Original Message- From: Python-list On Behalf Of Mark Bourne via Python-list Sent: Thursday, April 4, 2024 3:04 PM To: python-list@python.org Subject: Re: A technique from a chatbot Thomas Passin wrote: O

Re: A technique from a chatbot

2024-04-04 Thread Mark Bourne via Python-list
Thomas Passin wrote: On 4/2/2024 1:47 PM, Piergiorgio Sartor via Python-list wrote: On 02/04/2024 19.18, Stefan Ram wrote:    Some people can't believe it when I say that chatbots improve    my programming productivity. So, here's a technique I learned    from a chatbot!    It is a structured