Re: Making 'compiled' modules work with multiple python versions on Linux

2024-03-29 Thread Barry via Python-list
> On 28 Mar 2024, at 16:13, Olivier B. via Python-list > wrote: > > But on Linux, it seems that linking to libpython3.so instead of > libpython3.11.so.1.0 does not have the same effect, and results in > many unresolved python symbols at link time > > Is this functionality only available on

Re: A missing iterator on itertools module?

2024-03-28 Thread ast via Python-list
Le 28/03/2024 à 18:07, Stefan Ram a écrit : ast wrote or quoted: s1 = "AZERTY" s2 = "QSDFGH" s3 = "WXCVBN" and I need an itertor who delivers A Q W Z S C E D C ... I didn't found anything in itertools to do the job. So I came up with this solution: list(chain.from_iterable(zip("AZERTY",

Re: A missing iterator on itertools module?

2024-03-28 Thread ast via Python-list
Le 28/03/2024 à 17:45, ast a écrit : A Q W Z S C E D C ... sorry A Q W Z S X E D C -- https://mail.python.org/mailman/listinfo/python-list

A missing iterator on itertools module?

2024-03-28 Thread ast via Python-list
Hello Suppose I have these 3 strings: s1 = "AZERTY" s2 = "QSDFGH" s3 = "WXCVBN" and I need an itertor who delivers A Q W Z S C E D C ... I didn't found anything in itertools to do the job. So I came up with this solution: list(chain.from_iterable(zip("AZERTY", "QSDFGH", "WXCVBN"))) ['A',

Making 'compiled' modules work with multiple python versions on Linux

2024-03-28 Thread Olivier B. via Python-list
I have a python module that includes some C++ code that links with the Python C API I have now modified the c++ code so that it only uses the Limited API, and linked with python3.lib instead of python311.lib. I can now use that python module with different python versions on Windows But on

RE: Popping key causes dict derived from object to revert to object (3/25/2024)

2024-03-27 Thread Dr. F. M. (Mike) Covington via Python-list
Hello, all. I guess I'm just not seeing this dictionary pop() problem you're having. What version of Python are you using? Is there something I'm missing? If I've made an obvious oversight, please forgive me and explain. Thanks! PyCharm (2023.1.1) REPL running Python 3.12:

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

2024-03-25 Thread AVI GROSS via Python-list
Lori, The list comprehension you are thinking of does work if you change things a bit. But it is not a great idea as a main purpose of a dict is that using a hash means things are found in linear time. A comprehension iterates on all values. If you wanted to select just some items to keep in a

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

2024-03-25 Thread AVI GROSS via Python-list
I am glad, Lori, you found a solution another way. Actually, Lori, I think you were right in looking for a built-in method that complements pop() by returning everything else other than the item mentioned. There are philosophical and practical considerations that were no doubt considered and a

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

2024-03-25 Thread Grant Edwards via Python-list
On 2024-03-25, Loris Bennett via Python-list wrote: > Grant Edwards writes: > >> On 2024-03-22, Loris Bennett via Python-list wrote: >> >>> Yes, I was mistakenly thinking that the popping the element would >>> leave me with the dict minus the popped key-value pair. >> >> It does. > > Indeed,

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

2024-03-25 Thread Loris Bennett via Python-list
"Michael F. Stemper" writes: > On 25/03/2024 01.56, Loris Bennett wrote: >> Grant Edwards writes: >> >>> On 2024-03-22, Loris Bennett via Python-list wrote: >>> Yes, I was mistakenly thinking that the popping the element would leave me with the dict minus the popped key-value pair.

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

2024-03-25 Thread Jon Ribbens via Python-list
On 2024-03-25, Loris Bennett wrote: > "Michael F. Stemper" writes: > >> On 25/03/2024 01.56, Loris Bennett wrote: >>> Grant Edwards writes: >>> On 2024-03-22, Loris Bennett via Python-list wrote: > Yes, I was mistakenly thinking that the popping the element would >

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

2024-03-25 Thread Michael F. Stemper via Python-list
On 25/03/2024 01.56, Loris Bennett wrote: Grant Edwards writes: On 2024-03-22, Loris Bennett via Python-list wrote: Yes, I was mistakenly thinking that the popping the element would leave me with the dict minus the popped key-value pair. It does. Indeed, but I was thinking in the

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

2024-03-25 Thread Loris Bennett via Python-list
Grant Edwards writes: > On 2024-03-22, Loris Bennett via Python-list wrote: > >> Yes, I was mistakenly thinking that the popping the element would >> leave me with the dict minus the popped key-value pair. > > It does. Indeed, but I was thinking in the context of dict_list = [d.pop('a')

Re: ANN: EmPy 4.1 -- a powerful, robust and mature templating system for Python

2024-03-25 Thread Barry via Python-list
You should considered also announcing on https://discuss.python.org/ which is a lot more active then this list. Barry > On 25 Mar 2024, at 04:13, Erik Max Francis via Python-list > wrote: > > I'm pleased to announce the release of EmPy 4.1. > > The 4._x_ series is a modernization of the

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

2024-03-25 Thread Loris Bennett via Python-list
writes: > Loris wrote: > > "Yes, I was mistakenly thinking that the popping the element would leave > me with the dict minus the popped key-value pair. Seem like there is no > such function." > > Others have tried to explain and pointed out you can del and then use the > changed dict. > > But

Re: the name ``wheel''

2024-03-24 Thread Barry via Python-list
> On 22 Mar 2024, at 20:28, Mats Wichmann via Python-list > wrote: > > pip is still a separate package in the .rpm world. which makes sense on a > couple of levels: Yes it’s a separate package, but it’s always installed. At least on Fedora. I agree it makes sense to package it separately,

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

2024-03-24 Thread Frank Millman via Python-list
On 2024-03-23 3:25 PM, Frank Millman via Python-list wrote: It is not pretty! call_soon_threadsafe() is a loop function, but the loop is not accessible from a different thread. Therefore I include a reference to the loop in the message passed to in_queue, which in turn passes it to

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

2024-03-23 Thread Frank Millman via Python-list
On 2024-03-22 12:08 PM, Thomas Nyberg via Python-list 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

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: the name ``wheel''

2024-03-22 Thread Mats Wichmann via Python-list
On 3/22/24 11:45, Barry via Python-list wrote:  On 22 Mar 2024, at 15:25, Gilmeh Serda via Python-list wrote: Many if not most Linux distributions do not include pip by default. Really? It came with Manjaro. Debian and Ubuntu require you to install pip as a separate package. Also puts

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

2024-03-22 Thread Dieter Maurer via Python-list
dieter.mau...@online.de wrote at 2024-3-22 18:28 +0100: >Thomas Nyberg wrote at 2024-3-22 11:08 +0100: >> ... `future` use across thread boundaries ... >> Here's an example using just the standard library that >> exhibits the same issue: > ... >For use across thread boundaries, you likely will use

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

2024-03-22 Thread AVI GROSS via Python-list
Loris wrote: "Yes, I was mistakenly thinking that the popping the element would leave me with the dict minus the popped key-value pair. Seem like there is no such function." Others have tried to explain and pointed out you can del and then use the changed dict. But consider the odd concept of

Re: the name ``wheel''

2024-03-22 Thread Barry via Python-list
 > On 22 Mar 2024, at 15:25, Gilmeh Serda via Python-list > wrote: > >> Many if not most Linux distributions do not include pip by default. > > Really? It came with Manjaro. Debian and Ubuntu require you to install pip as a separate package. Also puts venv in its own package. Fedora leaves

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

2024-03-22 Thread Dieter Maurer via Python-list
Thomas Nyberg wrote at 2024-3-22 11:08 +0100: > ... `future` use across thread boundaries ... > Here's an example using just the standard library that > exhibits the same issue: I think all `asyncio` objects (futures, tasks, ...) are meant to be used in a single thread. If you use them across

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

2024-03-22 Thread Grant Edwards via Python-list
On 2024-03-22, Loris Bennett via Python-list wrote: > Yes, I was mistakenly thinking that the popping the element would > leave me with the dict minus the popped key-value pair. It does. > Seem like there is no such function. Yes, there is. You can do that with either pop or del: >>> d =

Re: the name ``wheel''

2024-03-22 Thread Thomas Schweikle via Python-list
Am Do., 21.März.2024 um 18:58:26 schrieb Johanne Fairchild via Python-list: r...@zedat.fu-berlin.de (Stefan Ram) writes: Johanne Fairchild wrote or quoted: Why is a whl-package called a ``wheel''? Is it just a pronunciation for the extension WHL or is it really a name? PyPi in its

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

2024-03-22 Thread Loris Bennett via Python-list
Mark Bourne writes: > 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 >>

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 Frank Millman via Python-list
On 2024-03-22 1:23 PM, Frank Millman via Python-list wrote: On 2024-03-22 12:09 PM, Frank Millman via Python-list wrote: I am no expert. However, I do have something similar in my app, and it works. I do not use 'await future', I use 'asyncio.wait_for(future)'. I tested it and it did not

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

2024-03-22 Thread Frank Millman via Python-list
On 2024-03-22 12:09 PM, Frank Millman via Python-list wrote: I am no expert. However, I do have something similar in my app, and it works. I do not use 'await future', I use 'asyncio.wait_for(future)'. I tested it and it did not work. I am not sure, but I think the problem is that you

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

2024-03-22 Thread Lars Liedtke via Python-list
Sorry, must have missed that :-/ Lars Liedtke Lead Developer [Tel.] +49 721 98993- [Fax] +49 721 98993- [E-Mail]l...@solute.de solute GmbH Zeppelinstraße 15 76185 Karlsruhe Germany [Marken] Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd

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

2024-03-22 Thread Frank Millman via Python-list
On 2024-03-20 10:22 AM, Thomas Nyberg via Python-list wrote: Hello, I have a simple (and not working) example of what I'm trying to do. This is a simplified version of what I'm trying to achieve (obviously the background workers and finalizer functions will do more later): `app.py` ```

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

2024-03-22 Thread Thomas Nyberg via Python-list
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 import threading

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

2024-03-22 Thread Chris Angelico via Python-list
On Fri, 22 Mar 2024 at 18:35, Lars Liedtke via Python-list wrote: > > Hey, > > As far as I know (might be old news) flask does not support asyncio. > > You would have to use a different framework, like e.g. FastAPI or similar. > Maybe someone has already written "flask with asyncio" but I don't

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

2024-03-22 Thread Lars Liedtke via Python-list
Hey, As far as I know (might be old news) flask does not support asyncio. You would have to use a different framework, like e.g. FastAPI or similar. Maybe someone has already written "flask with asyncio" but I don't know about that. Cheers Lars Lars Liedtke Lead Developer [Tel.] +49 721

Re: the name ``wheel''

2024-03-21 Thread Thomas Passin via Python-list
On 3/21/2024 4:19 PM, Grant Edwards via Python-list wrote: On 2024-03-21, MRAB via Python-list wrote: As it's recommended to use the Python Launcher py on Windows, I use that instead: py -m pip install something because it gives better support if you have multiple versions of Python

Re: the name ``wheel''

2024-03-21 Thread Grant Edwards via Python-list
On 2024-03-21, MRAB via Python-list wrote: > As it's recommended to use the Python Launcher py on Windows, I use > that instead: > > py -m pip install something > > because it gives better support if you have multiple versions of > Python installed. I adopted that practice years ago on Linux as

Re: the name ``wheel''

2024-03-21 Thread MRAB via Python-list
On 2024-03-21 11:36, Johanne Fairchild via Python-list wrote: Why is a whl-package called a ``wheel''? Is it just a pronunciation for the extension WHL or is it really a name? Also, it seems that when I install Python on Windows, it doesn't come with pip ready to run. I had to say python

Re: the name ``wheel''

2024-03-21 Thread Johanne Fairchild via Python-list
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Johanne Fairchild wrote or quoted: >>Why is a whl-package called a ``wheel''? Is it just a pronunciation for >>the extension WHL or is it really a name? > > PyPi in its initial state was named "cheese shop", as the famous > part in the show

Re: the name ``wheel''

2024-03-21 Thread Left Right via Python-list
I believe that the name "Wheel" was a reference to "reinventing the wheel". But I cannot find a quote to support this claim. I think the general sentiment was that it was the second attempt by the Python community to come up with a packaging format (first being Egg), and so they were reinventing

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

2024-03-21 Thread Dieter Maurer via Python-list
Loris Bennett wrote at 2024-3-21 10:56 +0100: > ... >So as I understand it, I need to convert the InstanceState-objects to, >say, dicts, in order to print them. However I also want to remove one >of the keys from the output and assumed I could just pop it off each >event dict, thus: > >

the name ``wheel''

2024-03-21 Thread Johanne Fairchild via Python-list
Why is a whl-package called a ``wheel''? Is it just a pronunciation for the extension WHL or is it really a name? Also, it seems that when I install Python on Windows, it doesn't come with pip ready to run. I had to say python -m ensurepip and then I saw that a pip on a whl-package was

Popping key causes dict derived from object to revert to object

2024-03-21 Thread Loris Bennett via Python-list
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 which says The

Using a background thread with asyncio/futures with flask

2024-03-20 Thread Thomas Nyberg via Python-list
Hello, I have a simple (and not working) example of what I'm trying to do. This is a simplified version of what I'm trying to achieve (obviously the background workers and finalizer functions will do more later): `app.py` ``` import asyncio import threading import time from queue import

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-20 Thread Roel Schroeven via Python-list
Op 19/03/2024 om 0:44 schreef Gilmeh Serda via Python-list: On Mon, 18 Mar 2024 10:09:27 +1300, dn wrote: > YMMV! > NB your corporate Style Guide may prefer 'the happy path'... If you only want to check for None, this works too: >>> name = None >>> dafault_value = "default" >>> name or

Re: GIL-Removal Project Takes Another Step (Posting On Python-List Prohibited)

2024-03-20 Thread Chris Angelico via Python-list
On Wed, 20 Mar 2024 at 18:31, Greg Ewing via Python-list wrote: > > On 20/03/24 4:14 pm, Lawrence D'Oliveiro wrote: > > not to > > mention the latency when there isn’t quite enough memory for an allocation > > and you have to wait until the next GC run to proceed. Run the GC a > > thousand times

Re: GIL-Removal Project Takes Another Step (Posting On Python-List Prohibited)

2024-03-20 Thread Greg Ewing via Python-list
On 20/03/24 4:14 pm, Lawrence D'Oliveiro wrote: not to mention the latency when there isn’t quite enough memory for an allocation and you have to wait until the next GC run to proceed. Run the GC a thousand times a second, and the latency is still 1 millisecond. That's not the way it usually

Re: Configuring an object via a dictionary

2024-03-19 Thread Pokemon Chw via Python-list
It's too complicated, there's no need for this def __init__(self, config): self.__dict__ = config self.connection = None """ other code . """ Note that you need to keep the fields in the config dict named the same as the fields you want to be

[RELEASE] Python 3.10.14, 3.9.19, and 3.8.19 is now available

2024-03-19 Thread Łukasz Langa via Python-list
Howdy! Those are the boring security releases that aren’t supposed to bring anything new. But not this time! We do have a bit of news, actually. But first things first: go update your systems!

Re: Configuring an object via a dictionary

2024-03-18 Thread Loris Bennett via Python-list
Tobiah writes: > I should mention that I wanted to answer your question, > but I wouldn't actually do this. I'd rather opt for > your self.config = config solution. The config options > should have their own namespace. > > I don't mind at all referencing foo.config['option'], > or you could

Re: Configuring an object via a dictionary

2024-03-18 Thread Tobiah via Python-list
I should mention that I wanted to answer your question, but I wouldn't actually do this. I'd rather opt for your self.config = config solution. The config options should have their own namespace. I don't mind at all referencing foo.config['option'], or you could make foo.config an object by

Re: Configuring an object via a dictionary

2024-03-18 Thread Tobiah via Python-list
On 3/15/24 02:30, Loris Bennett 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'] However, with a view to asking

Re: Configuring an object via a dictionary

2024-03-18 Thread Anders Munch via Python-list
dn wrote: >Loris Bennett wrote: >> However, with a view to asking forgiveness rather than >> permission, is there some simple way just to assign the dictionary >> elements which do in fact exist to self-variables? > >Assuming config is a dict: > > self.__dict__.update( config ) Here's

[Ann] managesieve v0.8 released

2024-03-18 Thread Hartmut Goebel via Python-list
Announcing: managesieve 0.8     RFC-5804 Manage Sieve client library for remotely managing Sieve scripts,     including an user application (the interactive 'sieveshell'). :Homepage: https://managesieve.readthedocs.io/ :Author:   Hartmut Goebel :License:   - for the managesieve

RE: Configuring an object via a dictionary

2024-03-17 Thread AVI GROSS via Python-list
If we are bringing up other languages, let's return to what was part of the original question. How van a dictionary be used in python if your goal is to sort of use it to instantiate it into a set of variables and values inside the local or global or other namespaces? Can we learn anything

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 Jim Schwartz via Python-list
Actually, I have a sleep disorder that requires me to keep a constant sleep schedule. Thats why I asked. Sent from my iPhone > On Mar 17, 2024, at 3:36 PM, dn via Python-list > wrote: > > On 17/03/24 23:40, Jim Schwartz wrote: >> Will it be recorded? > > Better than that (assumption)

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 NZPUG meets

Re: Configuring an object via a dictionary

2024-03-17 Thread Peter J. Holzer via Python-list
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 > > > > wrote: > > > > I've always like writing using

Re: MTG: Introductions to PyQt and DataClasses

2024-03-17 Thread Jim Schwartz via Python-list
Will it be recorded? Sent from my iPhone > On Mar 17, 2024, at 1:47 AM, dn via Python-list > wrote: > > 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

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 Peter J. Holzer via Python-list
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 production problem that using “or” > introducted.

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-16 Thread Thomas Passin via Python-list
On 3/16/2024 8:12 AM, Roel Schroeven via Python-list wrote: Barry via Python-list schreef op 16/03/2024 om 9:15: > 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 Roel Schroeven via Python-list
Barry via Python-list schreef op 16/03/2024 om 9:15: > 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

Re: Configuring an object via a dictionary

2024-03-16 Thread Barry via Python-list
> 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 because it fails on falsy values. Barry --

RE: Configuring an object via a dictionary

2024-03-15 Thread AVI GROSS via Python-list
A part of the Python view of the world is about a concept of whether something is "truthy" or not and thus many corners of the language do not care what kind of object an expression returns. If the object is returned in a context looking for not a Boolean value but a truth value, it is evaluated

Re: Configuring an object via a dictionary

2024-03-15 Thread Thomas Passin via Python-list
On 3/15/2024 5:33 PM, Dan Sommers via Python-list wrote: 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

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: 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: Configuring an object via a dictionary

2024-03-15 Thread Thomas Passin via Python-list
On 3/15/2024 3:09 PM, Grant Edwards via Python-list wrote: On 2024-03-15, Thomas Passin via Python-list wrote: On 3/15/2024 5:30 AM, Loris Bennett via Python-list wrote: Hi, I am initialising an object via the following: def __init__(self, config): self.connection = None

Re: Configuring an object via a dictionary

2024-03-15 Thread Grant Edwards via Python-list
On 2024-03-15, Thomas Passin via Python-list wrote: > On 3/15/2024 5:30 AM, 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 =

Re: Configuring an object via a dictionary

2024-03-15 Thread Thomas Passin via Python-list
On 3/15/2024 5:30 AM, 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: Configuring an object via a dictionary

2024-03-15 Thread Mats Wichmann via Python-list
On 3/15/24 03:30, Loris Bennett via Python-list wrote: Hi, I am initialising an object via the following: self.source_name = config['source_name'] config.get('source_name', default_if_not_defined) is a common technique... --

Configuring an object via a dictionary

2024-03-15 Thread Loris Bennett via Python-list
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'] self.server_port = config['server_port'] self.user_base =

[RELEASE] Python 3.13.0a5 is now available

2024-03-12 Thread Thomas Wouters via Python-list
We’re getting closer and closer… Alpha 5 is here. https://www.python.org/downloads/release/python-3130a5/ *This is an early developer preview of Python 3.13* Major new features of the 3.13 series, compared to 3.12 Python 3.13 is still in development. This release, 3.13.0a5, is the fifth of six

Re: A Single Instance of an Object?

2024-03-11 Thread Peter J. Holzer via Python-list
On 2024-03-11 16:53:00 -0400, Ivan "Rambius" Ivanov via Python-list wrote: > I am refactoring some code and I would like to get rid of a global > variable. Here is the outline: ... > The global cache variable made unit testing of the lookup(key) method > clumsy, because I have to clean it after

Re: A Single Instance of an Object?

2024-03-11 Thread Chris Angelico via Python-list
On Tue, 12 Mar 2024 at 08:04, Ivan "Rambius" Ivanov wrote: > > A Singleton is just a global variable. Why do this? Did someone tell > > you "global variables are bad, don't use them"? > > I have bad experience with global variables because it is hard to > track what and when modifies them. I

Re: A Single Instance of an Object?

2024-03-11 Thread Ivan "Rambius" Ivanov via Python-list
On Mon, Mar 11, 2024 at 5:06 PM dn via Python-list wrote: > > 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

Re: A Single Instance of an Object?

2024-03-11 Thread Ivan "Rambius" Ivanov via Python-list
On Mon, Mar 11, 2024 at 5:01 PM Chris Angelico via Python-list wrote: > > On Tue, 12 Mar 2024 at 07:54, Ivan "Rambius" Ivanov via Python-list > wrote: > > I am refactoring some code and I would like to get rid of a global > > variable. Here is the outline: > > > > ... > > > > I have never done

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: A Single Instance of an Object?

2024-03-11 Thread Chris Angelico via Python-list
On Tue, 12 Mar 2024 at 07:54, Ivan "Rambius" Ivanov via Python-list wrote: > I am refactoring some code and I would like to get rid of a global > variable. Here is the outline: > > ... > > I have never done that in Python because I deliberately avoided such > complicated situations up to now. I

A Single Instance of an Object?

2024-03-11 Thread Ivan "Rambius" Ivanov via Python-list
Hello, I am refactoring some code and I would like to get rid of a global variable. Here is the outline: import subprocess CACHE = {} def lookup(key): Runs the command cmd, parses its output, extract's the key's value, caches it and returns it. If the key has already been in the

Re: Error in Module

2024-03-11 Thread Sanskar Mukeshbhai Joshi via Python-list
Thank you for the information. On Mon, Mar 11, 2024, 22:36 wrote: > Sanskar Mukeshbhai Joshi wrote at 2024-3-10 18:08 +: > >I had made my project in BCA in Python. When I had complete my project > and run the program, at that time I got the error in runnig my project. The > error was

Re: Error in Module

2024-03-11 Thread Dieter Maurer via Python-list
Sanskar Mukeshbhai Joshi wrote at 2024-3-10 18:08 +: >I had made my project in BCA in Python. When I had complete my project and run >the program, at that time I got the error in runnig my project. The error was >ModuleNotFoundError: No module named 'flask'. `flask` is not part of the

Re: Error in Module

2024-03-11 Thread Alan Gauld via Python-list
On 10/03/2024 18:08, Sanskar Mukeshbhai Joshi via Python-list wrote: > I had made my project in BCA in Python. When I had complete my > project and run the program, at that time I got the error in > runnig my project. The error was ModuleNotFoundError: No module named 'flask'. Flask is a third

Error in Module

2024-03-11 Thread Sanskar Mukeshbhai Joshi via Python-list
Respected Sir/Ma'am I had made my project in BCA in Python. When I had complete my project and run the program, at that time I got the error in runnig my project. The error was ModuleNotFoundError: No module named 'flask'. I request you to check this problem and resolve it or guide me to solve

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Barry via Python-list
> On 10 Mar 2024, at 14:49, Thomas Passin via Python-list > wrote: > > That and there's a registry setting: > > https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation > Yep that and rules about size of parts of the path. Barry --

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Thomas Passin via Python-list
On 3/10/2024 9:33 AM, Albert-Jan Roskam wrote: On Mar 10, 2024 12:59, Thomas Passin via Python-list wrote: On 3/10/2024 6:17 AM, Barry wrote: > > >> On 8 Mar 2024, at 23:19, Thomas Passin via Python-list wrote: >> >> We just learned a few posts back that

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Albert-Jan Roskam via Python-list
On Mar 10, 2024 12:59, Thomas Passin via Python-list wrote: On 3/10/2024 6:17 AM, Barry wrote: > > >> On 8 Mar 2024, at 23:19, Thomas Passin via Python-list wrote: >> >> We just learned a few posts back that it might be specific to Linux; I ran it

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Thomas Passin via Python-list
On 3/10/2024 6:17 AM, Barry wrote: On 8 Mar 2024, at 23:19, Thomas Passin via Python-list wrote: We just learned a few posts back that it might be specific to Linux; I ran it on Windows. Depending on the exact win32 api used there is a 257 limit on windows. The 257 includes 2 for the

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Barry via Python-list
> On 8 Mar 2024, at 23:19, Thomas Passin via Python-list > wrote: > > We just learned a few posts back that it might be specific to Linux; I ran it > on Windows. Depending on the exact win32 api used there is a 257 limit on windows. The 257 includes 2 for the device, C:, and 255 for the

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Grant Edwards via Python-list
On 2024-03-08, Thomas Passin via Python-list wrote: > >> Hi, I tested this with Python 3.8. Good to know that this was fixed! > > We just learned a few posts back that it might be specific to Linux; I > ran it on Windows. On Linux, the limit is imposed by the filesystem. Most of the "real"

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Thomas Passin via Python-list
On 3/8/2024 5:14 PM, Albert-Jan Roskam wrote: On Mar 8, 2024 19:35, Thomas Passin via Python-list wrote: On 3/8/2024 1:03 PM, Albert-Jan Roskam via Python-list wrote: > Hi, > I was replacing some os.path stuff with Pathlib and I discovered this: >

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Albert-Jan Roskam via Python-list
On Mar 8, 2024 19:35, Thomas Passin via Python-list wrote: On 3/8/2024 1:03 PM, Albert-Jan Roskam via Python-list wrote: > Hi, > I was replacing some os.path stuff with Pathlib and I discovered this: > Path(256 * "x").is_file() # OSError >

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

2024-03-08 Thread Chris Angelico via Python-list
On Sat, 9 Mar 2024 at 03:42, Grant Edwards via Python-list wrote: > > On 2024-03-08, Chris Angelico via Python-list wrote: > > On Sat, 9 Mar 2024 at 00:51, Grant Edwards via Python-list > > wrote: > > > >> One might argue that "global" isn't a good choice for what to call the > >> scope in

Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-08 Thread Thomas Passin via Python-list
On 3/8/2024 2:21 PM, Grant Edwards via Python-list wrote: On 2024-03-08, Thomas Passin via Python-list wrote: On 3/8/2024 1:03 PM, Albert-Jan Roskam via Python-list wrote: Hi, I was replacing some os.path stuff with Pathlib and I discovered this: Path(256 * "x").is_file() #

<    1   2   3   4   5   6   7   8   9   10   >