Re: Cprod -- (writing this: itertools.product([0, 1], repeat=N )

2024-05-21 Thread dn via Python-list
On 22/05/24 07:14, HenHanna via Python-list wrote: How can i write this function Cprod (Cartesian Product) simply?     (writing this out: itertools.product([0, 1], repeat=N ) The value can be a list or a Tuple.     cprod([0, 1], 1) => ((0) (1))    

Data Ethics (Virtual) Meeting

2024-04-10 Thread dn via Python-list
Virtual meeting, Wed 17 April, 1800 for 1830 (NZST, ie 0630 UTC) Data Ethics Emma McDonald is the Director of the Interim Centre for Data Ethics and Innovation at Stats NZ (New Zealand Government Department of Statistics) Emma will talk about why Stats NZ is establishing a Centre for Data

Re: How to Add ANSI Color to User Response

2024-04-10 Thread dn via Python-list
On 11/04/24 06:50, WordWeaver Evangelist via Python-list wrote: I have a simple question. I use the following textPrompt in some of my Jython modules: '\nYour choice is? (A B C D E): ', maxChars=1, autoAccept=False, forceUppercase=True) Is there a way to add an ANSI color code to the

Re: Multiplication

2024-04-01 Thread dn via Python-list
The April Fools joke was on those of us who never received/have yet to receive @Stefan's OP. On 2/04/24 08:02, Avi Gross via Python-list wrote: Is this a April 1 post for fools. Multiplication with an asterisk symbol is built into python. The same symbol used in other contexts has other

Re: MTG: Introductions to PyQt and DataClasses

2024-03-17 Thread dn via Python-list
On 18/03/24 10:02, Jim Schwartz wrote: Actually, I have a sleep disorder that requires me to keep a constant sleep schedule. Thats why I asked. At a weekend meeting, discussion swirled around topics such as the best way to learn/work, how much work we should attempt in one sitting,

Re: Configuring an object via a dictionary

2024-03-17 Thread dn via Python-list
On 18/03/24 04:11, Peter J. Holzer via Python-list wrote: On 2024-03-17 17:15:32 +1300, dn via Python-list wrote: On 17/03/24 12:06, Peter J. Holzer via Python-list wrote: On 2024-03-16 08:15:19 +, Barry via Python-list wrote: On 15 Mar 2024, at 19:51, Thomas Passin via Python-list

Re: MTG: Introductions to PyQt and DataClasses

2024-03-17 Thread dn via Python-list
On 17/03/24 23:40, Jim Schwartz wrote: Will it be recorded? Better than that (assumption) "coming soon" - please join-up or keep an eye on PySprings' Meetup ANNs: https://www.meetup.com/pysprings/ On Mar 17, 2024, at 1:47 AM, dn via Python-list wrote: The Auckland Branch of N

MTG: Introductions to PyQt and DataClasses

2024-03-17 Thread dn via Python-list
The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 NZDT (0530 UTC, midnight-ish Tue/Wed in American time-zones), for a virtual meeting. Part 1: Learn the basics of PyQt with code examples. Hannan Khan is currently consulting as a Data Scientist for the (US) National Oceanic

Re: Configuring an object via a dictionary

2024-03-16 Thread dn via Python-list
On 17/03/24 12:06, Peter J. Holzer via Python-list wrote: On 2024-03-16 08:15:19 +, Barry via Python-list wrote: On 15 Mar 2024, at 19:51, Thomas Passin via Python-list wrote: I've always like writing using the "or" form and have never gotten bit I, on the other hand, had to fix a

Re: Configuring an object via a dictionary

2024-03-16 Thread dn via Python-list
On 16/03/24 21:15, Barry via Python-list wrote: On 15 Mar 2024, at 19:51, Thomas Passin via Python-list wrote: I've always like writing using the "or" form and have never gotten bit I, on the other hand, had to fix a production problem that using “or” introducted. I avoid this idiom

Re: Configuring an object via a dictionary

2024-03-15 Thread dn via Python-list
On 15/03/24 22:30, Loris Bennett via Python-list wrote: Hi, I am initialising an object via the following: def __init__(self, config): self.connection = None self.source_name = config['source_name'] self.server_host = config['server_host']

Re: A Single Instance of an Object?

2024-03-11 Thread dn via Python-list
Good question Rambius! On 12/03/24 09:53, Ivan "Rambius" Ivanov via Python-list wrote: Hello, I am refactoring some code and I would like to get rid of a global variable. Here is the outline: import subprocess CACHE = {} First thought: don't reinvent-the-wheel, use lru_cache

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread dn via Python-list
On 7/03/24 05:28, Jacob Kruger via Python-list wrote: ... So, yes, know this comes across like some form of a scam/joke, or list-garbage, since it doesn't make any sense to me at all, but still just wondering if missing something, or should I shift over to 3.12 to see if if works differently,

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-05 Thread dn via Python-list
Jacob, Please reduce the problem to a small code-set which reproduces the problem. If we can reproduce same, then that tells us something. At the very least, we can experiment without having to expend amounts of time in a (likely faulty) bid to reproduce the same environment. Also, code is

Re: Can one output something other than 'nan' for not a number values?

2024-02-19 Thread dn via Python-list
On 20/02/24 01:04, Chris Green via Python-list wrote: dn wrote: On 18/02/24 09:53, Grant Edwards via Python-list wrote: On 2024-02-17, Cameron Simpson via Python-list wrote: On 16Feb2024 22:12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like '-'

Re: Can one output something other than 'nan' for not a number values?

2024-02-19 Thread dn via Python-list
On 20/02/24 05:58, Grant Edwards via Python-list wrote: Here's a demonstration of how to hook custom code into the f-string formatting engine. It's brilliantly depraved. https://stackoverflow.com/questions/55876683/hook-into-the-builtin-python-f-string-format-machinery From the above:

Re: Testing (sorry)

2024-02-18 Thread dn via Python-list
On 19/02/24 12:09, Grant Edwards via Python-list wrote: ... But posts to the list still seemed to vanish into the ether while emails from both accounts reached other destinations without delay, During this process a number of posts from other users did appear in the list archive and at at

Re: Can one output something other than 'nan' for not a number values?

2024-02-18 Thread dn via Python-list
On 18/02/24 09:53, Grant Edwards via Python-list wrote: On 2024-02-17, Cameron Simpson via Python-list wrote: On 16Feb2024 22:12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like '-' or even just a space instead of the string 'nan'. [...]

Re: Using __new__

2024-02-17 Thread dn via Python-list
class S: (not disputing the concept of "object" as the base class) Not correct. Please see last paragraph from previous message: On Sat, Feb 17, 2024 at 7:06 PM dn via Python-list mailto:python-list@python.org>> wrote: ... PS please reply to the list - there may be oth

Re: Using __new__

2024-02-17 Thread dn via Python-list
On 18/02/24 12:48, Jonathan Gossage wrote: The problem that I am facing is that when the superclass is not 'object', the __init__ method may well need arguments. I do not know how to determine if the superclass is 'object'. For what it is worth, any attempt to use this with different arguments 

Re: Using __new__

2024-02-17 Thread dn via Python-list
On 18/02/24 11:35, Jonathan Gossage via Python-list wrote: I am attempting to use the __new__ method in the following code: class SingletonExample(object): _instance = None def __new__(cls, **kwargs): if cls._instance is None: cls._instance =

Re: test-ignore

2024-02-15 Thread dn via Python-list
On 16/02/24 13:29, Skip Montanaro via Python-list wrote: Test post to see if my Newsgroup post program is working. Aim your test messages at alt.test, please. I agree that basic Usenet connectivity messages should go to alt.test. It's not clear from the original post, but if the poster's

Re: Extract lines from file, add to new files

2024-02-04 Thread dn via Python-list
On 4/02/24 13:20, avi.e.gr...@gmail.com wrote: Dave, You and I have had some experience in teaching or tutoring others and I think it fair to say our motivation is closer to teaching someone how they can fish for themselves rather than just handing them a fully-cooked fish. Which may push

Re: Extract lines from file, add to new files

2024-02-03 Thread dn via Python-list
Every trainer, in any field, has to deal with these problems - all the time, and over-and-over. On 4/02/24 06:58, Thomas Passin via Python-list wrote: In my view this whole thread became murky and complicated because the OP did not write down the requirements for the program.  Requirements

MTG: pytest (NZPUG, Auckland, VacExcHndlrs)

2024-01-31 Thread dn via Python-list
Wed 7 Feb (evening NZDT) will be the last virtual gathering in the current Vacation Exception Handlers (VacExcHndlrs) series (https://danceswithmice.info/Python/2024/VacExcHndlrs.html). You are cordially-invited to join us to investigate the pytest Python testing framework. "The pytest

Re: Extract lines from file, add to new files

2024-01-29 Thread dn via Python-list
On 30/01/24 05:15, Rich Shepard via Python-list wrote: On Fri, 12 Jan 2024, Rich Shepard via Python-list wrote: For my use 1) the salutation and email address (always with an '@') are sequential and 2) I'm developing the script to extract both from the same file. I've looked at my Python

Re: Extract lines from file, add to new files

2024-01-15 Thread dn via Python-list
On 15/01/24 21:13, Greg Ewing via Python-list wrote: On 15/01/24 1:54 pm, dn wrote: Soon after, Wirth simplified rather than expanded, and developed Pascal. Before Pascal there was Algol-W, which Wirth invented as a rebellion against how complicated Algol 68 was becoming. When I first saw

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 14:45, Chris Angelico wrote: On Mon, 15 Jan 2024 at 12:42, dn via Python-list wrote: On 15/01/24 14:33, Chris Angelico via Python-list wrote: On Mon, 15 Jan 2024 at 12:12, dn via Python-list wrote: Here's another witticism I'll often toss at trainees (in many languages

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 14:33, Chris Angelico via Python-list wrote: On Mon, 15 Jan 2024 at 12:12, dn via Python-list wrote: Here's another witticism I'll often toss at trainees (in many languages, and especially in UX): just because we can do it, doesn't make it a good idea! Programming. We were so

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 11:47, Chris Angelico via Python-list wrote: On Mon, 15 Jan 2024 at 09:40, dn via Python-list wrote: The basic challenge came from my earlier (and blasé) repetition of the Python refrain "everything in Python is an object". Which led to: ... So, no, there's an "ev

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 08:06, AVI GROSS via Python-list wrote: ...> You provided a way to create an anonymous function and that was not enough. I wonder if you could throw in the new := walrus operator to similarly make a named lambda function in a similar way. Why would @Chris have anything to do with

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 01:28, Left Right wrote: Second time to ameliorate wording-dispute in this thread! The original phrase was: "[modified] BNF". Some of us have worked with various forms and evolutions of BNF since back in the days of COBOL-60 proposals, and know it when we see it! OK, here are the

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 10:23, Chris Angelico via Python-list wrote: On Mon, 15 Jan 2024 at 08:15, Left Right wrote: Python grammar rules prevent function definition from appearing in left-hand side of the head of the for loop. However, a variable declaration, which is also a statement, is allowed there.

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 14/01/24 16:48, Chris Angelico wrote: On Sun, 14 Jan 2024 at 14:43, dn via Python-list wrote: Similarly, whilst we could write: a, b, c = 1, 2, 3 I would only do this when it aligns particularly well with the algorithm being implemented. For example, you could start a Fibonacci

Re: Extract lines from file, add to new files

2024-01-13 Thread dn via Python-list
On 13/01/24 00:11, Left Right via Python-list wrote: To people discussing BNF: The grammar language Python uses is *very* far from BNF. It's more similar to PEG, but even then it's still quite far. Python's grammar is just its own thing, which makes it harder to read, if you are already

Mtg: Object-Oriented VacExcHndlrs (UTC+13)

2024-01-13 Thread dn via Python-list
Let's meet on Wednesday (17Jan, 1600 NZDT (UTC+13), wearing a head-set) to talk about Object-Oriented everything. Is O-O worthwhile, or does is it just a load of guys running around and getting no-where? NB this is not a formal PUG-meeting. It's part of the "Vacation Exception Handlers"

Re: Extract lines from file, add to new files

2024-01-13 Thread dn via Python-list
On 12/01/24 08:53, Rich Shepard via Python-list wrote: On Thu, 11 Jan 2024, Piergiorgio Sartor via Python-list wrote: Why not to use bash script for all? Piergiorgio, That's certainly a possibility, and may well be better than python for this task. (sitting in a meeting with little to

Re: Extract lines from file, add to new files

2024-01-11 Thread dn via Python-list
On 12/01/24 12:56, Chris Angelico via Python-list wrote: On Fri, 12 Jan 2024 at 08:56, Left Right via Python-list wrote: By the way, in an attempt to golf this problem, I discovered this, which seems like a parser problem: When you jump immediately to "this is a bug", all you do is make

Re: Extract lines from file, add to new files

2024-01-11 Thread dn via Python-list
On 12/01/24 10:33, Left Right via Python-list wrote: By the way, in an attempt to golf this problem, I discovered this, which seems like a parser problem: This is what Python tells me about its grammar: with_stmt: | 'with' '(' ','.with_item+ ','? ')' ':' block | 'with' ','.with_item+

Re: A problem with str VS int.

2023-12-12 Thread dn via Python-list
On 12/12/23 21:22, Steve GS wrote: With all these suggestions on how to fix it, no one seems to answer why it fails only when entering a two-digit number. One and three work fine when comparing with str values. It is interesting that the leading 0 on a two digit worked. Still, one digit and

Re: A problem with str VS int.

2023-12-09 Thread dn via Python-list
On 10/12/23 15:42, Steve GS via Python-list wrote: If I enter a one-digit input or a three-digit number, the code works but if I enter a two digit number, the if statement fails and the else condition prevails. tsReading = input(" Enter the " + Brand + " test strip reading: ")

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

2023-12-06 Thread dn via Python-list
On 7/12/23 07:12, MRAB via Python-list wrote: On 2023-12-06 12:23, Thomas Passin via Python-list wrote: On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote: On 6 Dec 2023, at 09:32, Chris Green via Python-list wrote: My requirement is *slightly* more complex than just key value

NZPUG Mtg: Making Python faster, and "Dependency Inversion"

2023-11-22 Thread dn via Python-list
Virtual meeting: Wednesday 6 December, 1815 for 1830 NZDT/UTC+13 Book at https://www.meetup.com/nzpug-auckland/events/295433876/ 1 Making Python faster - using type hints Tushar will lead us through: A brief history of type hints Using type checkers to verify your type hints

Re: Newline (NuBe Question)

2023-11-15 Thread dn via Python-list
On 15/11/2023 20.25, Grizzy Adams via Python-list wrote: Hi & thanks for patience with what could be simple to you Have this (from an online "classes" tutorial) There are lots of on-line classes! --- Start Code Snippit --- students = [] grades = [] for s in geographyClass:

Clearing the Deque • Picturing Python’s `deque` data structure

2023-11-07 Thread dn via Python-list
You will be welcome to join us at our next (hybrid) meeting: Wednesday, 15 November 2023, 1815~2030 NZDT (0515~0730 UTC). How often do you use a deque*? “Not very” is a common answer. Perhaps you’ve never used it. In this presentation, Stephen won’t try to convince you to use it more often.

Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread dn via Python-list
On 08/11/2023 06.47, Egon Frerich via Python-list wrote: I've no idea why this happens. In a module there are lists and definitions: ...     ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in Felder])   File "/home/egon/Entw/Geldspur/geldspur/gui/GUI_Konfig.py", line 90, in    

Safe package removal

2023-11-05 Thread dn via Python-list
After thread: "pip/pip3 confusion and keeping up to date" Over the years?centuries, have added various packages, using all of: - distribution-installer (dnf/yum - per apt-get) - su pip install, and - (user) pip install Because Fedora-Linux can be upgraded in-place. an amount of 'crud'

Re: Checking if email is valid

2023-11-02 Thread dn via Python-list
On 02/11/2023 20.28, Simon Connah wrote: I'm not sure that would be practical. As I'm setting up a mailing list server I don't know if someone in the future is going to need to use one of those aliases and testing manually would be tedious. Please re-read. Discussion is about "closeness".

Re: Checking if email is valid

2023-11-02 Thread dn via Python-list
On 02/11/2023 19.56, Chris Angelico via Python-list wrote: On Thu, 2 Nov 2023 at 17:47, Simon Connah wrote: My goal is to make a simple mailing list platform. I guess I could just send email to an address and if it bounces then I can remove it from the database. Thing is I'm not sure how

Re: Checking if email is valid

2023-11-02 Thread dn via Python-list
On 02/11/2023 19.46, Simon Connah via Python-list wrote: On Thu, 2 Nov 2023 at 05:21, Simon Connah via Python-list python-list@python.org wrote: Could someone push me in the right direction please? I just want to find out if a string is a valid email address. There is only one way

Re: Checking if email is valid

2023-11-01 Thread dn via Python-list
On 02/11/2023 00.35, Simon Connah via Python-list wrote: OK. I've been doing some reading and that you should avoid regex to check email addresses. This operation used to be a BIG THING back in the days of 'everyone' building PHP web-sites. When there were only a handful of TLDs (top-level

Re: Too Broad of an exception

2023-10-25 Thread dn via Python-list
On 26/10/2023 04.49, rsutton via Python-list wrote: On 10/25/2023 11:06 AM, Stefan Ram wrote: r...@zedat.fu-berlin.de (Stefan Ram) writes: outer quotation marks) prints some prominent exception types. After ...    "Manually removing" above was meant to be a fast first pass,    where I only

Re: return type same as class gives NameError.

2023-10-22 Thread dn via Python-list
On 23/10/2023 04.50, Antoon Pardon via Python-list wrote: I have the following small module: =-=-=-=-=-=-=-=-=-=-=-= 8< =-=-=-=-=-=-=-=-=-=-=-=-= from typing import NamedTuple, TypeAlias, Union from collections.abc import Sequence PNT: TypeAlias = tuple[float, float] class Pnt (NamedTuple):

Re: Where I do ask for a new feature

2023-10-20 Thread dn via Python-list
On 21/10/2023 01.32, Thomas Passin via Python-list wrote: On 10/19/2023 11:16 PM, Bongo Ferno via Python-list wrote: On Thursday, October 19, 2023 at 11:26:52 PM UTC-3, avi.e...@gmail.com wrote: There are many ways to make transient variables that disappear at some time and do we need yet

Re: type annotation vs working code

2023-10-04 Thread dn via Python-list
On 04/10/2023 19.41, Chris Angelico via Python-list wrote: On Wed, 4 Oct 2023 at 15:27, dn via Python-list wrote: - should the class have been called either; class SomethingSingleton(): or a Singleton() class defined, which is then sub-classed, ie class Something( Singleton

Re: type annotation vs working code

2023-10-03 Thread dn via Python-list
On 02/10/2023 00.57, Karsten Hilbert via Python-list wrote: Sorry for having conflated the core of the matter with all the Borg shenanigans, that's where I found the problem in my real code, so there :-) The first question when dealing with the Singleton Pattern is what to do when more than

Re: type annotation vs working code

2023-09-30 Thread dn via Python-list
On 01/10/2023 11.25, Karsten Hilbert via Python-list wrote: Am Sun, Oct 01, 2023 at 09:04:05AM +1300 schrieb dn via Python-list: class WorkingSingleton(Borg): def __init__(self): print(self.__class__.__name__, ':') try

Re: type annotation vs working code

2023-09-30 Thread dn via Python-list
On 01/10/2023 08.00, Karsten Hilbert via Python-list wrote: A type annotation isn't supposed to change what code does, or so I thought: # class Borg: _instances:dict = {} def __new__(cls, *args, **kargs):

Re: path to python in venv

2023-09-27 Thread dn via Python-list
On 28/09/2023 09.32, Jon Ribbens via Python-list wrote: On 2023-09-27, Larry Martell wrote: On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list wrote: On 2023-09-27, Larry Martell wrote: I was under the impression that in a venv the python used would be in the venv's bin dir. But

Re: Python Launcher Pops Up When Py-based App Is Running (Mac)

2023-09-18 Thread dn via Python-list
On 17/09/2023 13.20, James Greenham via Python-list wrote: Hello, On the face of it, the Python-Mac mailing list is largely inactive so I'm posting here since it looks like this one is livelier. What happens when doGrab() is called from the REPL, after being 'fed' data you expect is valid?

ANN: Wed 20 Sep: Terminal-based user interfaces (TUIs) with ease using Textual

2023-09-07 Thread dn via Python-list
Rodrigo's back! Fresh from his successes at EuroPython... You are invited to join the next virtual NZPUG Auckland Branch meeting (Wed 20 Sep, 1830~2030 local, ie 0630~0830 UTC) Learn how to build powerful terminal-based user interfaces (TUIs) with ease using Textual - an open-source Python

Co-op Group: Django web framework

2023-08-28 Thread dn via Python-list
Are you interested in learning Django? Would like to improve your Django knowledge and skills? Have you been picking-up Django piecemeal, and need to consolidate and clarify? Do you know some Django and would like to acquire mentoring and coaching skills? If so, please join us to form a

Re: Context manager for database connection

2023-08-23 Thread dn via Python-list
On 24/08/2023 06.11, dn via Python-list wrote: On 24/08/2023 03.41, Jason Friedman via Python-list wrote: with Database() as mydb: conn = mydb.get_connection() cursor = conn.get_cursor() cursor.execute("update table1 set x = 1 where y = 2") cursor.close() cursor = conn.

Re: Context manager for database connection

2023-08-23 Thread dn via Python-list
On 24/08/2023 03.41, Jason Friedman via Python-list wrote: I want to be able to write code like this: with Database() as mydb: conn = mydb.get_connection() cursor = conn.get_cursor() cursor.execute("update table1 set x = 1 where y = 2") cursor.close() cursor = conn.get_cursor()

Re: Imports and dot-notation

2023-08-09 Thread dn via Python-list
On 09/08/2023 22.30, Oliver Schinagl via Python-list wrote: ...> Looking at a python projects code and repository layout, we see the following directory structure. /project/core /project/components/module1 ... /project/components/moduleN /projects/util ...> Some modules import other modules,

Re: Planning a Python / PyData conference

2023-08-08 Thread dn via Python-list
Hi Wilber, On 09/08/2023 14.28, Wilber H via Python-list wrote: Hi, I would like to plan a Python / PyData conference in the country of the Dominican Republic, and would like your feedback on how to best plan for the conference. Recommend making your request of the folks who organise

Mtg ANN: Using computer vision AI to help protect the worlds rarest dolphin

2023-08-08 Thread dn via Python-list
Wed 16 Aug 2023, 1800~20:30 NZST (0600~0830 UTC, late-Tue in US) Details and RSVP at https://www.meetup.com/nzpug-auckland/events/295091858/ Teaching a computer to see. How computer vision is helping to protect the world’s rarest dolphin and how you can train your own model. Tane van der

Re: Where is the error?

2023-08-06 Thread dn via Python-list
On 07/08/2023 08.41, Peter J. Holzer via Python-list wrote: Mostly, error messages got a lot better in Python 3.10, but this one had me scratching my head for a few minutes. ... The error message is now a lot better, of course, but the fact that it points at the expression *before* the error

Re: isinstance()

2023-08-04 Thread dn via Python-list
On 05/08/2023 11.18, Chris Angelico via Python-list wrote: On Sat, 5 Aug 2023 at 09:08, dn via Python-list wrote: On 03/08/2023 11.38, Jon Ribbens via Python-list wrote: On 2023-08-02, dn wrote: Can you please explain why a multi-part second-argument must be a tuple and not any other form

Re: isinstance()

2023-08-04 Thread dn via Python-list
On 03/08/2023 11.38, Jon Ribbens via Python-list wrote: On 2023-08-02, dn wrote: Can you please explain why a multi-part second-argument must be a tuple and not any other form of collection-type? The following comment may hold a clue: if (PyTuple_Check(cls)) { /* Not a general

Re: How to find the full class name for a frame

2023-08-03 Thread dn via Python-list
On 04/08/2023 15.34, Jason Friedman via Python-list wrote: import inspect def my_example(arg1, arg2): print(inspect.stack()[0][3]) my_frame = inspect.currentframe() args,_,_,values = inspect.getargvalues(my_frame) args_rendered = [f"{x}: {values[x]}" for x in args] print(args_rendered)

isinstance()

2023-08-02 Thread dn via Python-list
Can you please explain why a multi-part second-argument must be a tuple and not any other form of collection-type? The signature is: isinstance(object, classinfo) leading to "classinfo" of: 1/ a single class/type, eg int 2/ a tuple of same, eg ( int, str, ) 3/ a union type, eg int | str

Hybrid meeting ANN: Using properties and descriptors

2023-07-11 Thread dn via Python-list
This month's meeting (Wed 19 July, 1800 for 1830 NZST = 0600/0630 UTC) will cover more-advanced OOP Python skills. You will be most-welcome to join us... "Using properties and descriptors" will look at a series of code-examples exploring problems and how these constructs offer solutions.

Re: my excel file is not updated to add new data

2023-06-26 Thread dn via Python-list
Marc, Apologies for writing in English (the language of this Discussion List). I have attempted to keep the code in French... Thanks for this question. If it's OK with you, I would like to use it as an example-problem (and 'solution') challenge for some future Python Users' Group meeting

Re: Python Issue

2023-06-21 Thread dn via Python-list
On 22/06/2023 03.28, Pickle Pork via Python-list wrote: Python is unable to open. Exit Code: 1 This is not good. Please give some useful information: - from where did you download Python? - which operating system? - how do you "open" Python? etc. -- Regards, =dn --

Re: Should NoneType be iterable?

2023-06-19 Thread dn via Python-list
On 20/06/2023 06.12, Neal Becker via Python-list wrote: On Mon, Jun 19, 2023 at 12:42 PM Chris Angelico via Python-list < python-list@python.org> wrote: On Tue, 20 Jun 2023 at 02:37, Peter Bona via Python-list wrote: Hi I am wondering if there has been any discussion why NoneType is not

Re: Enum + new in 3.11

2023-06-16 Thread dn via Python-list
On 16/06/2023 23.47, Thomas Passin via Python-list wrote: On 6/16/2023 1:40 AM, dn via Python-list wrote: Have you figured-out a use for the @enum.member and @enum.nonmember decorators (new in Python 3.11)? mypy is having trouble with 3.11 enums: "There are 83 open Enum mypy i

Enum + new in 3.11

2023-06-15 Thread dn via Python-list
Have you figured-out a use for the @enum.member and @enum.nonmember decorators (new in Python 3.11)? "What's New" says: Added the member() and nonmember() decorators, to ensure the decorated object is/is not converted to an enum member. The PSL docs say: @enum.member A decorator for use

Re: Best practice for database connection

2023-05-31 Thread dn via Python-list
On 01/06/2023 06.45, Thomas Passin wrote: On 5/31/2023 2:10 PM, Jason Friedman wrote: I'm trying to reconcile two best practices which seem to conflict. 1) Use a _with_ clause when connecting to a database so the connection is closed in case of premature exit. class_name =

Re: complaint

2023-05-30 Thread dn via Python-list
Hi Daniel, On 31/05/2023 02.40, Daniel Ifechukwude Dibie wrote: i tried to uninstall the python 3.11.3 program from my machine so that i can re-install it is showing successful but it is ligerning on the program and features Is that word "lingering". If so, do you mean that Python did not

Re: OT: Addition of a .= operator

2023-05-23 Thread dn via Python-list
On 24/05/2023 12.27, Chris Angelico wrote: On Wed, 24 May 2023 at 10:12, dn via Python-list wrote: However, (continuing @Peter's theme) such confuses things when something goes wrong - was the error in the input() or in the float()? - particularly for 'beginners' - and yes, we can expand

OT: Addition of a .= operator

2023-05-23 Thread dn via Python-list
On 24/05/2023 10.21, Rob Cliffe via Python-list wrote: This sort of code might be better as a single expression. For example: user = ( request.GET["user"] .decode("utf-8") .strip() .lower() ) user = orm.user.get(name=user) LOL.  And I thought I was the one with a

Re: Addition of a .= operator

2023-05-20 Thread dn via Python-list
On 21/05/2023 05.54, Alex Jando wrote: I have many times had situations where I had a variable of a certain type, all I cared about it was one of it's methods. For example: import hashlib hash = hashlib.sha256(b'word') hash =

Re: Disable 'style PEP' messages

2023-05-04 Thread dn via Python-list
On 05/05/2023 04.28, Kevin M. Wilson via Python-list wrote: Hi... How do I set Pycharm to find only syntax errors?!! Please review response to previous message re:configuring PyCharm's helpful features towards to coders and quality-coding... -- Regards, =dn --

Re: Question regarding unexpected behavior in using __enter__ method

2023-04-20 Thread dn via Python-list
On 21/04/2023 10.44, Lorenzo Catoni wrote: 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: It is expected behavior - just not what WE might have

Re: Pycharm IDE

2023-04-19 Thread dn via Python-list
On 20/04/2023 08.59, Thomas Passin wrote: On 4/19/2023 4:06 PM, Mark Bourne wrote: print(f'{LIMIT}) ^ I think this one should be: print(f'{LIMIT}') with the closing quote ;o) Yup a typo!  Where's pylint when I need it? but (and you designed it this way - right?) an excellent

Re: PyCharm's strict PEP and not so strict?

2023-04-19 Thread dn via Python-list
be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze." *Isaiah 43:2* On Wednesday, April 19, 2023 at 11:39:36 AM MDT, dn via Python-list wrote: On 20/04/2023 04.25,

Re: PyCharm's strict PEP and not so strict?

2023-04-19 Thread dn via Python-list
On 20/04/2023 04.25, Alan Gauld wrote: On 19/04/2023 10:51, Kevin M. Wilson via Python-list wrote:  I'm in a bit of a quandary, I want some strict syntax errors to be flagged, OK, You might want to use a "linter" in that case because most tools use the interpreter itself to flag syntax

Re: Pycharm IDE

2023-04-19 Thread dn via Python-list
On 19/04/2023 21.13, Kevin M. Wilson wrote: Sorry the code snippet I sent was what is written in PyCharm. LIMIT is defined and is not causing an error! PyCharm is flagging the Parentheses at the end. It is not seeing the Parentheses as the end of the print function. def play_game(): number=

Re: Pycharm IDE

2023-04-19 Thread dn via Python-list
Kevin, As mentioned in another response, the format of these messages seems very confused. Please copy-paste all of (the pertinent part of) the code, and ensure that the line-endings are in the correct places, tab/indentation looks correct, etc? (this will allow us to copy the same code

Re: Pycharm IDE

2023-04-18 Thread dn via Python-list
On 19/04/2023 11.18, Kevin M. Wilson via Python-list wrote: Greetings... Kevin here:I need help, as you have guessed!I have this line: The Print Statement... Why complain about a 'comma', or a ')'???def play_game(): number = random.randint(1, LIMIT) print (f'"I am thinking of a number

Dataclasses, immutability(?), and ChatGPT

2023-04-11 Thread dn via Python-list
Are dataclasses (or instances thereof) mutable or immutable? - and in what sense? Have been experimenting with ChatGPT. In particular: its possibilities as a trainer, good ideas for methods of introducing new topics, its capability for drawing-up demonstrations or examples, its interpretation

Re: Initialising a Config class

2023-04-11 Thread dn via Python-list
On 12/04/2023 02.29, Loris Bennett wrote: Hi, Having solved my problem regarding setting up 'logger' such that it is ... My reading suggests that setting up a module with a Config class which can be imported by any part of the program might be a reasonable approach: ... However, in my

Re: When is logging.getLogger(__name__) needed?

2023-04-05 Thread dn via Python-list
Thank you for carefully considering suggestions (and implications) - and which will 'work' for you. Further comment below (and with apologies that, unusually for me, there are many personal opinions mixed-in):- On 06/04/2023 01.06, Loris Bennett wrote: "Loris Bennett" writes: dn writes:

Re: [Python-Dev] Small lament...

2023-04-03 Thread dn via Python-list
On 04/04/2023 12.14, Guido van Rossum wrote: A bit late, this reached my inbox: https://peternorvig.medium.com/new-python-operators-9f31b56ddcc7 Did you notice that Peter Norvig's factorial-operator attempts to replace one of the very first diamond-grade provisions of [the] FLUFL?

Re: Windows Gui Frontend

2023-04-02 Thread dn via Python-list
On 03/04/2023 02.45, Michael Torrie wrote: On 4/2/23 05:09, Dietmar Schwertberger wrote: I also did evaluate all the GUI builder from time to time between 2000 and 2016 to find one that I could recommend to colleagues, but could not find one. Then I started contributing to wxGlade and I can

Re: When is logging.getLogger(__name__) needed?

2023-03-31 Thread dn via Python-list
On 01/04/2023 02.01, Loris Bennett wrote: Hi, In my top level program file, main.py, I have def main_function(): parser = argparse.ArgumentParser(description="my prog") ... args = parser.parse_args() config = configparser.ConfigParser() if

Re: Python file location

2023-03-29 Thread dn via Python-list
On 30/03/2023 09.47, windhorn wrote: I have an older laptop I use for programming, particularly Python and Octave, running a variety of Debian Linux, and I am curious if there is a "standard" place in the file system to store this type of program file. OK, I know they should go in a repository

Re: Standard class for time *period*?

2023-03-28 Thread dn via Python-list
1. Is there a standard class for a 'period', i.e. length of time specified by a start point and an end point? The start and end points could obviously be datetimes and the difference a timedelta, but the period '2022-03-01 00:00 to 2022-03-02 00:00' would be different to '2023-03-01

Re: Friday finking: IDE 'macro expansions'

2023-03-18 Thread dn via Python-list
On 19/03/2023 01.27, 2qdxy4rzwzuui...@potatochowder.com wrote: On 2023-03-18 at 11:49:24 +, "Weatherby,Gerard" wrote: For templating, I have two Python programs for starting new work. One generates a standalone Python program with the Python shebang, a __main__ which calls def main(), and

  1   2   3   4   >