Re: PEP668 / pipx and "--editable" installs

2023-09-16 Thread Karsten Hilbert via Python-list
Am Sat, Sep 16, 2023 at 02:17:19PM +1200 schrieb Rimu Atkinson via Python-list: > Everyone uses virtual environments. Umm, like, no. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list

Re: pip/pip3 confusion and keeping up to date

2023-11-03 Thread Karsten Hilbert via Python-list
Am Thu, Nov 02, 2023 at 09:35:43PM - schrieb Jon Ribbens via Python-list: Regardless of ... > Because pip barely plays well by itself, let alone with other package > managers at the same time. ... being true ... > > I do only install a few things using pip. > > Are they not available in

Re: pip/pip3 confusion and keeping up to date

2023-11-04 Thread Karsten Hilbert via Python-list
Am Thu, Nov 02, 2023 at 04:07:33PM -0600 schrieb Mats Wichmann via Python-list: > >So they now have only python3 and there is no python executable in > >PATH. > > FWIW, for this you install the little stub package python-is-python3. > Especially if you > want to keep a python2 installation

Aw: Re: pip/pip3 confusion and keeping up to date

2023-11-07 Thread Karsten Hilbert via Python-list
> > .From all the posts I gather the answer to my question is > > "simply": unpackaged-but-needed modules need to be packaged. > > I think there is one aspect that isn't getting consideration here. And > that is whether or not you want these packages installed in the default > system Python

Re: pip/pip3 confusion and keeping up to date

2023-11-05 Thread Karsten Hilbert via Python-list
Am Sun, Nov 05, 2023 at 03:00:41PM + schrieb Chris Green via Python-list: > > * contact every single maintainer of every single one of the packages > > that needs updating and persuade them to update their packages and > > reassure them that you are getting all the other package

Re: pip/pip3 confusion and keeping up to date

2023-11-05 Thread Karsten Hilbert via Python-list
Am Fri, Nov 03, 2023 at 01:53:32PM - schrieb Jon Ribbens via Python-list: > >> Are they not available in your system's package manager? > > > > ... this clearly often answers to "no" for applications of > > any complexity. > > > > Is there a suggested proper path to deal with that (Debian is

Re: pip/pip3 confusion and keeping up to date

2023-11-05 Thread Karsten Hilbert via Python-list
Am Fri, Nov 03, 2023 at 05:26:06PM +0100 schrieb Dieter Maurer: > Karsten Hilbert wrote at 2023-11-3 14:47 +0100: > > ... > >> Are they not available in your system's package manager? > > > >... this clearly often answers to "no" for applications of > >any complexity. > > > >Is there a suggested

Re: pip/pip3 confusion and keeping up to date

2023-11-06 Thread Karsten Hilbert via Python-list
Am Mon, Nov 06, 2023 at 01:17:11AM - schrieb Jon Ribbens via Python-list: > >> >> Are they not available in your system's package manager? > >> > > >> > ... this clearly often answers to "no" for applications of > >> > any complexity. > >> > > >> > Is there a suggested proper path to deal

Re: pip/pip3 confusion and keeping up to date

2023-11-06 Thread Karsten Hilbert via Python-list
Am Mon, Nov 06, 2023 at 08:58:00AM +0100 schrieb Dieter Maurer: > I know that debian packagers create debian packages > from Python distributions not using the approach sketched above > and likely they have their reasons. > > You might want to discuss this on an `apt` related mailing list. Yeah,

Re: pip/pip3 confusion and keeping up to date

2023-11-06 Thread Karsten Hilbert via Python-list
Am Mon, Nov 06, 2023 at 02:43:47PM -0700 schrieb Mats Wichmann via Python-list: > >I had just hoped someone here might have a handy pointer for > >how to deal with modules having to be installed from pip for > >use with an apt-installed python-based application. > > That just shouldn't happen -

Aw: Re: Any possible type alias that can also set a default value for a function arg?

2023-10-19 Thread Karsten Hilbert via Python-list
> > or something like that. Basically, any way to avoid writing `= None` over > > and over again. > > Fundamentally no, at least not without some shenanigans. Type hints do > not affect the regular running of the code, Except when they do ;-) ... depending on what counts as (valid) code ... In

type annotation vs working code

2023-09-30 Thread Karsten Hilbert via Python-list
A type annotation isn't supposed to change what code does, or so I thought: # class Borg: _instances:dict = {} def __new__(cls, *args, **kargs): # look up subclass instance cache if

Re: type annotation vs working code

2023-09-30 Thread Karsten Hilbert via Python-list
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: > > self.already_initialized > > print('already

Re: type annotation vs working code

2023-10-01 Thread Karsten Hilbert via Python-list
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 :-) Consider this: # class Surprise: def __init__(self, with_type_annotation=False):

Aw: Re: Re: Re: Any possible type alias that can also set a default value for a function arg?

2023-10-19 Thread Karsten Hilbert via Python-list
> > As per my recent foray into abusing existence-checking for Singleton > > assurance > > along such lines as > > > > >>> try: self.initialized > > >>> except AttributeError: print('first instantiation'); self.initialized = > > >>> True > > > > and then changing that to > > > > >>> try:

Aw: Re: Re: Any possible type alias that can also set a default value for a function arg?

2023-10-19 Thread Karsten Hilbert via Python-list
> > > Fundamentally no, at least not without some shenanigans. Type hints do > > > not affect the regular running of the code, > > > > Except when they do ;-) > > > > ... depending on what counts as (valid) code ... > > > > In Python a distinction can be made between "runnable" and "valid" :-D > >

Re: type annotation vs working code

2023-10-04 Thread Karsten Hilbert via Python-list
Am Wed, Oct 04, 2023 at 05:25:04PM +1300 schrieb dn via Python-list: > The first question when dealing with the Singleton Pattern is what to do when > more than > one instantiation is attempted: > > - silently return the first instance This, in my case. > and so, returning to the matter of

Aw: Re: Re: mypy question

2023-12-30 Thread Karsten Hilbert via Python-list
> I'm fairly sure your database queries don't actually give you strings or > dicts, right? You probably get lists (or iterators) of tuples and > somewhere you convert them to the arguments you are feeding to > run_queries(). Ah, no, those queries are enshrined within the middleware as Python

Aw: Re: mypy question

2023-12-30 Thread Karsten Hilbert via Python-list
Dear Thomas, thanks for taking the time to look into my issue. Maybe it helps if I explain what I want (sorry that my web mailer does not respect indentation, I will insert dots). I want a function to run SQL queries: run_queries(conn, queries): ...for q in queries: ..conn.execute(q) I

Aw: Re: Re: mypy question

2023-12-30 Thread Karsten Hilbert via Python-list
> It occurs to me that you could simplify things if you converted those > plain query strings to dicts: > > 'SELECT 1' --> {'SQL': 'SELECT 1'} Ha, indeed. There's likely not that many "simple string SQL queries" in that codebase so I shall take it as an opportunity to refactor them. So, at least

Aw: Re: mypy question

2023-12-30 Thread Karsten Hilbert via Python-list
Hi Greg, > dict[str, str] is not a subtype of dict[str, str | something_else] > because you can assign a value of type something_else to the latter > but not the former. I understand what you are saying but I do not yet understand why this applies to my situation. I don't have Python at hand

Re: mypy question

2023-12-31 Thread Karsten Hilbert via Python-list
Thanks to all. I ended up using Sequence for the list part and Mapping for the dict part, which does require "import typing" which I would rather have avoided. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list

mypy question

2023-12-29 Thread Karsten Hilbert via Python-list
Hi all, I am not sure why mypy thinks this gmPG2.py:554: error: Argument "queries" to "run_rw_queries" has incompatible type "List[Dict[str, str]]"; expected "List[Dict[str, Union[str, List[Any], Dict[str, Any" [arg-type] rows, idx = run_rw_queries(link_obj = conn,

Re: mypy question

2023-12-29 Thread Karsten Hilbert via Python-list
Am Fri, Dec 29, 2023 at 01:15:29PM +0100 schrieb Karsten Hilbert via Python-list: > I am not sure why mypy thinks this > > gmPG2.py:554: error: Argument "queries" to "run_rw_queries" has incompatible > type "List[Dict[str, str]]"; expected > "

Re: mypy question

2023-12-29 Thread Karsten Hilbert via Python-list
Am Fri, Dec 29, 2023 at 07:49:17AM -0700 schrieb Mats Wichmann via Python-list: > >I am not sure why mypy thinks this > > > >gmPG2.py:554: error: Argument "queries" to "run_rw_queries" has incompatible > >type "List[Dict[str, str]]"; expected > >"List[Dict[str, Union[str, List[Any], Dict[str,

Re: mypy question

2023-12-29 Thread Karsten Hilbert via Python-list
Am Fri, Dec 29, 2023 at 11:04:59AM -0700 schrieb Mats Wichmann via Python-list: > >For what it's worth here's the signature of that function: > > > > def run_rw_queries ( > > link_obj:_TLnkObj=None, > > queries:list[dict[str, str | list | dict[str, Any]]]=None, > >

Re: mypy question

2024-01-13 Thread Karsten Hilbert via Python-list
Am Fri, Jan 12, 2024 at 02:23:43PM +0100 schrieb Antoon Pardon via Python-list: > > queries:list[dict[str, str | list | dict[str, Any]]]=None, > > > >into > > > > "List[Dict[str, Union[str, List[Any], Dict[str, Any" > > > >seems accurate. I just don't understand why list[dict[str, >

Re: mypy question

2024-01-13 Thread Karsten Hilbert via Python-list
Am Sat, Jan 13, 2024 at 09:20:00PM +0100 schrieb Karsten Hilbert via Python-list: > > I was wondering if > > your type hint for queries shouldn't be the following. > > > > queries:list[dict[str,str]|dict[str,list]|dict[str,dict[str, dict[str, > > Ant]]] Wait, not

Aw: Re: Re: Extract lines from file, add to new files

2024-01-30 Thread Karsten Hilbert via Python-list
> > Why not foxus on just the part you think you are better off using python, > > namely personalization ? > > > > Create personalized files and send them with your trusted mailx solution ? > > Karsten, > > Too much time. And while mailx accepts the '-a' option for attachments but > has none for

Aw: Re: Re: Re: Extract lines from file, add to new files

2024-01-30 Thread Karsten Hilbert via Python-list
> On Tue, 30 Jan 2024, Karsten Hilbert wrote: > > > It doesn't need to. It just sends the (pre-personalized-by-Python) mail > > files. > > Karsten, > > In which case, I might as well have Python format and send the messages. :-) Certainly. But it seems you are wrestling with Python. Might as

Aw: Re: Extract lines from file, add to new files

2024-01-30 Thread Karsten Hilbert via Python-list
> For 30 years I've used a bash script using mailx to send messages to a list > of recipients. They have no salutation to personalize each one. Since I want > to add that personalized salutation I decided to write a python script to > replace the bash script. Why not foxus on just the part you