Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)

2024-09-10 Thread Karsten Hilbert via Python-list
Am Tue, Sep 10, 2024 at 08:38:30AM - schrieb Jon Ribbens via Python-list: > Ok. So we've moved away from "In any DBMS worth its salt, rollback is > something that happens automatically" Nope. The original post asked something entirely different. > and now you're saying it isn't automatic aft

Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)

2024-09-09 Thread Karsten Hilbert via Python-list
Am Mon, Sep 09, 2024 at 10:00:11AM - schrieb Jon Ribbens via Python-list: > So the Python code is half-way through a transaction when it throws > a (non-database-related) exception and that thread of execution is > aborted. The database connection returns to the pool, How does it return to th

Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)

2024-09-09 Thread Karsten Hilbert via Python-list
Am Mon, Sep 09, 2024 at 10:00:11AM - schrieb Jon Ribbens via Python-list: > > The database only needs to commit when it is explicitly told. Anything > > less -- no commit. > > So the Python code is half-way through a transaction when it throws > a (non-database-related) exception and that thre

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-09 Thread Karsten Hilbert via Python-list
Am Mon, Sep 09, 2024 at 01:48:32PM +1200 schrieb Greg Ewing via Python-list: > That code doesn't inspire much confidence in me. It's far too > convoluted with too much micro-management of exceptions. It is catching two exceptions, re-raising both of them, except for re-raising one of them as anot

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-09 Thread Karsten Hilbert via Python-list
Am Mon, Sep 09, 2024 at 01:48:32PM +1200 schrieb Greg Ewing via Python-list: > That code doesn't inspire much confidence in me. It's far too > convoluted with too much micro-management of exceptions. > > I would much prefer to have just *one* place where exceptions are > caught and logged. I am o

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Karsten Hilbert via Python-list
Am Sun, Sep 08, 2024 at 02:58:03PM +0100 schrieb Rob Cliffe via Python-list: > >Ugly: > > > > try: > > do something > > except: > > log something > > finally: > > try: > > .commit() > > except: > >

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Karsten Hilbert via Python-list
Am Sun, Sep 08, 2024 at 12:48:50PM +1200 schrieb Greg Ewing via Python-list: > On 8/09/24 9:20 am, Karsten Hilbert wrote: > > try: > > do something > > except: > > log something > > finally: > > .commit(

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-08 Thread Karsten Hilbert via Python-list
Am Sun, Sep 08, 2024 at 12:48:50PM +1200 schrieb Greg Ewing via Python-list: > On 8/09/24 9:20 am, Karsten Hilbert wrote: > > try: > > do something > > except: > > log something > > finally: > > .commit(

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Karsten Hilbert via Python-list
Am Sat, Sep 07, 2024 at 02:09:28PM -0700 schrieb Adrian Klaver: > >Right, and this was suggested elsewhere ;) > > > >And, yeah, the actual code is much more involved :-D > > > > I see that. > > The question is does the full code you show fail? > > The code sample you show in your original post is

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Karsten Hilbert via Python-list
Am Sat, Sep 07, 2024 at 01:03:34PM -0700 schrieb Adrian Klaver: > In the case you show you are doing commit() before the close() so any errors > in the > transactions will show up then. My first thought would be to wrap the > commit() in a > try/except and deal with error there. Right, and this

Re: psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Karsten Hilbert via Python-list
Am Sat, Sep 07, 2024 at 09:46:03AM -0700 schrieb Adrian Klaver: > >unto now I had been thinking this is a wise idiom (in code > >that needs not care whether it fails to do what it tries to > >do^1): > > > > conn = psycopg2.connection(...) > > In the above do you have: > > https://www.psycopg.o

psycopg2: proper positioning of .commit() within try: except: blocks

2024-09-07 Thread Karsten Hilbert via Python-list
Dear all, unto now I had been thinking this is a wise idiom (in code that needs not care whether it fails to do what it tries to do^1): conn = psycopg2.connection(...) curs = conn.cursor() try: curs.execute(SOME_SQL) except PSYCOPG2-Exception:

Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread Karsten Hilbert via Python-list
Am Sun, May 19, 2024 at 10:45:09PM +0100 schrieb Barry via Python-list: > > On 18 May 2024, at 16:27, Peter J. Holzer via Python-list > > wrote: > > > > I don't think Linux users have to deal with venvs > > Modern debian (ubuntu) and fedora block users installing using pip. > You must use a venv

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

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: 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 thi

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,

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, > >s

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

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 stri

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
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 no

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 cur

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

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, Any

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 > "

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, queri

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 instal

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 - su

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 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 with

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 main

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 &

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 around

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 you

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: self.ini

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

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

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 'rea

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):

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 ini

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 Borg._i

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

Aw: Re: Windows Gui Frontend

2023-04-02 Thread Karsten Hilbert
> The real time consuming stuff in building GUIs is getting > the basic design right and keeping all the controls, > keyboard bindings and menus in sync. State management > in other words. And cominmg up with sensible design choices _at all_. > I did a deep dive examination of GUI builders back a

Aw: Re: Standard class for time *period*?

2023-03-28 Thread Karsten Hilbert
> No, it doesn't. I already know about timedelta. I must have explained > the issue badly, because everyone seems to be fixating on the > formatting, which is not a problem and is incidental to what I am really > interested in, namely: > > 1. Is there a standard class for a 'period', i.e. length

Aw: Re: Python 3.10 Fizzbuzz

2023-02-28 Thread Karsten Hilbert
> > I've never tried Black or any other code formatter, but I'm sure we > > wouldn't get on. > > Does this suggest, that because Black doesn't respect other people's > opinions and feelings, that it wouldn't meet the PSF's Code of Conduct? That much depends on The Measure Of A Man. Karsten -- ht

Re: TypeError: can only concatenate str (not "int") to str

2023-02-27 Thread Karsten Hilbert
Am Sun, Feb 26, 2023 at 08:56:28AM -0800 schrieb Hen Hanna: > so far, i think Paul Rubin's post (in another thread) was > esp. concise, informative, --- but he's also made a comment > about 'shunting' beginners (questions) to a > concentration camp, and sounded a bit like a cold-he

Re: pylint scoping question

2023-02-08 Thread Karsten Hilbert
Am Wed, Feb 08, 2023 at 12:20:48PM +0100 schrieb Karsten Hilbert: > I have a pylint scoping (or how-to) question. ... > Objective: > > to disable all pylint errors/warnings starting from a > particular source line until EOF (that part contains > to-be-run-manually scratch/test

pylint scoping question

2023-02-08 Thread Karsten Hilbert
Dear readers, I have a pylint scoping (or how-to) question. pylint 2.7.2 astroid 2.5.1 Python 3.9.2 (default, Feb 28 2021, 17:03:44) Objective: to disable all pylint errors/warnings starting from a particular source line until EOF (that part contains to-be-run-manually s

Re: Are these good ideas?

2022-11-14 Thread Karsten Hilbert
Am Mon, Nov 14, 2022 at 05:14:05PM + schrieb Stephen Tucker: > Issue 2 - Passed Parameters > > I am now facing another situation where I am wanting to pass 6 or 7 > parameters down through several layers of logic (function A calling > function B calling ... ) and for results to be passed back.

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-14 Thread Karsten Hilbert
Am Mon, Nov 14, 2022 at 02:13:34AM + schrieb MRAB: > But if it's an expression where it's expecting a statement and it's not a > call, then > it's probably a bug. That "probably" makes it suitable for a linter, as was pointed out. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4

"mailcap" to be removed (3.13) -- suggested replacement ?

2022-10-26 Thread Karsten Hilbert
Dear list, Python 3.11 marks "mailcap" for removal in 3.13. The documentation speaks about "mimetypes" being a replacement, of sorts. I agree with removing dead batteries. However, I can't really see how "mimetypes" helps in replacing the functionality of "mailcap" ? Put another way: what is the

Re: A trivial question that I don't know - document a function/method

2022-10-23 Thread Karsten Hilbert
Am Sun, Oct 23, 2022 at 05:16:48PM -0400 schrieb Thomas Passin: > > def make_title_from_headline(self, p, h) -> str: > > > > def plot(self, stackposition=MAIN, clearFirst=True) -> None: > 1. Knowing the type of a parameter isn't all you usually want to know; Sure, as I said: > >and use

Re: A trivial question that I don't know - document a function/method

2022-10-23 Thread Karsten Hilbert
Am Sat, Oct 22, 2022 at 09:49:55PM -0400 schrieb Thomas Passin: > def make_title_from_headline(self, p, h): > """From node title, return title with over- and underline- strings. ... >RETURNS >a string > """ > def plot(self, stackposition=MAIN, clearFirst=True): > "

Aw: Re: for -- else: what was the motivation?

2022-10-17 Thread Karsten Hilbert
> which had special combinations for all the BASIC keywords). And if you > go this way, why not go a step further and dissociate the program from > its linear text representation? Add footnotes, different views, > hyperlinks, format mathematical expressions like formulas, etc. http://literateprogr

Re: for -- else: what was the motivation?

2022-10-10 Thread Karsten Hilbert
Am Sun, Oct 09, 2022 at 09:58:14AM + schrieb Stefan Ram: > I often follow this rule. For me, it's about readability. Compare: > > if not open( disk ): > error( "Can't open disk" ) > else: > printf( "now imagine there's some larger block here" ) ... ad infinitum

Re: What to use for finding as many syntax errors as possible.

2022-10-09 Thread Karsten Hilbert
Am Sun, Oct 09, 2022 at 07:51:12PM +0200 schrieb Antoon Pardon: > >But the point is: you can't (there is no way to) be sure the > >9+ errors really are errors. > > > >Unless you further constrict what sorts of errors you are > >looking for and what margin of error or leeway for false > >positives

Re: What to use for finding as many syntax errors as possible.

2022-10-09 Thread Karsten Hilbert
Am Sun, Oct 09, 2022 at 06:59:36PM +0200 schrieb Antoon Pardon: > Op 9/10/2022 om 17:49 schreef Avi Gross: > >My guess is that finding 100 errors might turn out to be misleading. If you > >fix just the first, many others would go away. > > At this moment I would prefer a tool that reported 100 err

Re: for -- else: what was the motivation?

2022-10-09 Thread Karsten Hilbert
Am Sun, Oct 09, 2022 at 05:37:59AM +0100 schrieb Axy via Python-list: > Python is awesome because it's semantic is clear for the majority, but there > are places > that look odd. In case of "for", "else" looks logically tied with "for" > clause, but > actually it is not. It's tied with "break" s

Aw: Re: Subtract n months from datetime [Why?]

2022-06-22 Thread Karsten Hilbert
> What makes sense depends on where you're looking from. > > It's 28 February, you need to keep it for 5 years, therefore you could > reason that you can dispose of it on 28 February, 5 years hence. > > However, that happens to be a leap year. > > Should you still have it on 29 February? Nope beca

Re: How to replace characters in a string?

2022-06-08 Thread Karsten Hilbert
Am Wed, Jun 08, 2022 at 11:09:05AM +0200 schrieb Dave: > myString = 'Hello' > myNewstring = myString.replace(myString,'e','a’) That won't work (last quote) but apart from that: myNewstring = myString.replace('e', 'a') Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https:

Re: Automatic Gain Control in Python?

2022-06-06 Thread Karsten Hilbert
Am Mon, Jun 06, 2022 at 02:08:41PM -0400 schrieb Steve GS: > Yes, it is real-time play back of a pre-recorded presentation. ... What all of us around here don't understand is why you insist on not being able to modify the data to your heart's content inbetween this ... > [...] pulling in the pro

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-17 Thread Karsten Hilbert
Am Sun, Apr 17, 2022 at 11:10:01AM +1200 schrieb Greg Ewing: > On 17/04/22 9:17 am, Karsten Hilbert wrote: > > Take this medication for 1 month ! > > > >is quite likely to mean "take it for 28 days". > > Except when your doctor prescribes 90 days worth of

Re: Pre-Pre-PEP: The datetime.timedeltacal class

2022-04-16 Thread Karsten Hilbert
Am Sat, Apr 16, 2022 at 07:35:51PM +0200 schrieb Peter J. Holzer: > So I'll start by gathering some feedback > here with a rough sketch. > [TODO: Research how other systems handle overflow > (e.g. 2022-01-31 + 1 month: 2022-02-31 doesn't exist)], That is context dependant: Take this med

Aw: Re: Best way to check if there is internet?

2022-02-22 Thread Karsten Hilbert
> Is there any value whatsoever in a lie? Do we _know_ it's a lie ? Does a lie become a Falsed Truth once it becomes known ? Karsten -- https://mail.python.org/mailman/listinfo/python-list

Aw: PYT - How can I subscribe to a topic in the mailing list?

2022-02-19 Thread Karsten Hilbert
> Betreff: PYT - How can I subscribe to a topic in the mailing list? Mailing lists don't subdivide by topic. Your mailer may allow you to filter by Subject:. > And h*ow do I set the topic in my messages?* not applicable The equivalent would be the Subject: header. Karsten -- https://mail.pyt

Aw: Re: Long running process - how to speed up?

2022-02-19 Thread Karsten Hilbert
> > I have a cvs file of 932956 row and have to have time.sleep in a Python > > script. It takes a long time to process. > > > > How can I speed up the processing? Can I do multi-processing? > > > Remove the time.sleep()? He's attesting to only having "time.sleep" in there... I doubt removing t

Aw: Re: Best way to check if there is internet?

2022-02-07 Thread Karsten Hilbert
> Or the internet acquires a new protocol that's designed > for very-long-latency connections. That's being worked on already https://en.wikipedia.org/wiki/NASA_Deep_Space_Network Karsten -- https://mail.python.org/mailman/listinfo/python-list

Re: builtins.TypeError: catching classes that do not inherit from BaseException is not allowed

2021-12-31 Thread Karsten Hilbert
Am Thu, Dec 30, 2021 at 03:57:25PM -0800 schrieb hongy...@gmail.com: > > > Then what cases/scenarios can demonstrate the beauty of recursion? > > > > > Walking a tree. > > There are many type of trees. Do you mean all of them? Palm trees don't lend themselves to recursion all that much. Karsten

Re: How to apply a self defined function in Pandas

2021-10-31 Thread Karsten Hilbert
Am Sun, Oct 31, 2021 at 07:52:18PM + schrieb Shaozhong SHI: > Well, can you expand the the simplicity? Not sure how expanding is going to help but here's one way to do it: Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linux Type "help", "copyr

Aw: Re: The task is to invent names for things

2021-10-28 Thread Karsten Hilbert
> Karsten Hilbert writes: > >ite is the -te form (in some uses like a gerundium) of aru > >(to go, to walk) > > This form, "行って", is written with two "t", as "itte", > in many transcriptions to convey the gemination (っ) of > the &qu

Aw: Re: The task is to invent names for things

2021-10-27 Thread Karsten Hilbert
> > I don't know. A mediocre name conveys at least some information, and > > that seems to be better than none. On the other hand it might be just > > enough to lead the reader astray which wouldn't happen with a > > non-sensical name. I was thinking that a nonsensical name might lead readers to g

Re: The task is to invent names for things

2021-10-27 Thread Karsten Hilbert
Am Wed, Oct 27, 2021 at 12:41:56PM +0200 schrieb Karsten Hilbert: > Am Tue, Oct 26, 2021 at 11:36:33PM + schrieb Stefan Ram: > > > xyzzy = lambda x: 2 * x > > > > . Sometimes, this can even lead to "naming paralysis", where > > one thinks excessive

Re: The task is to invent names for things

2021-10-27 Thread Karsten Hilbert
Am Wed, Oct 27, 2021 at 10:00:16PM +1100 schrieb Chris Angelico: > > Am Wed, Oct 27, 2021 at 10:20:19AM +1100 schrieb Chris Angelico: > > > > > Many operations in computing are fully reversible. After you do > > > something, you can undo it. After you assign, you can unassign. And > > > after you

Re: The task is to invent names for things

2021-10-27 Thread Karsten Hilbert
Am Tue, Oct 26, 2021 at 11:36:33PM + schrieb Stefan Ram: > xyzzy = lambda x: 2 * x > > . Sometimes, this can even lead to "naming paralysis", where > one thinks excessively long about a good name. To avoid this > naming paralysis, one can start out with a mediocre name. In > the course

Re: The task is to invent names for things

2021-10-27 Thread Karsten Hilbert
Am Wed, Oct 27, 2021 at 10:20:19AM +1100 schrieb Chris Angelico: > Many operations in computing are fully reversible. After you do > something, you can undo it. After you assign, you can unassign. And > after you ite, you can unite! I wonder whether Japanese programmers would agree. Karsten -- G

Re: Definitive guide for Regex

2021-10-05 Thread Karsten Hilbert
Am Thu, Sep 30, 2021 at 12:29:16PM +0100 schrieb Shaozhong SHI: > I am trying to look for a definitive guide for Regex in Python. > Can anyone help? If you tell us what you tried in order to look we can perhaps guide you on how to take a better look. Spoonfeeding doesn't seem to be a well-liked

Re: XML Considered Harmful

2021-09-28 Thread Karsten Hilbert
Am Tue, Sep 28, 2021 at 12:53:49PM -0500 schrieb Michael F. Stemper: > This sounds like a suggestion that I hard-code the data into a > module. I suppose that I could have half-a-dozen modules with > different data sets and ln them as required: > > $ rm GenData.py* FuelData.py* > $ ln gendata1.py

Re: XML Considered Harmful

2021-09-25 Thread Karsten Hilbert
Am Fri, Sep 24, 2021 at 08:59:23PM +0200 schrieb Peter J. Holzer: > JSON: Has a few primitive data types (bool, number, string) and a two > compound types (list, dict(string -> any)). Still missing many > frequently used data types (e.g. dates) But that (dates) at least has a well-known mapping t

Re: googletrans in python

2021-04-12 Thread Karsten Hilbert
Am Mon, Apr 12, 2021 at 12:48:23PM -0400 schrieb Quentin Bock: > Can someone explain the basics of googletrans in python? > I want to make a program that translates stories into English, but I'm not > sure how to get a translation printed. Also, is this needed to be done in > an HTML file inside p

Aw: not able to download PyAudio

2021-04-02 Thread Karsten Hilbert
The same as with speech recognition. Research. Karsten > Gesendet: Freitag, 02. April 2021 um 10:40 Uhr > Von: "ᗷᑌᑎᑎY" > An: "Igor Korot" > Cc: "python-list@python.org" > Betreff: not able to download PyAudio > >Hello everyone >I am not able to download PyAudio. I tried by typing pip

Re: .title() - annoying mistake

2021-03-22 Thread Karsten Hilbert
Am Mon, Mar 22, 2021 at 09:22:51AM + schrieb Robert Latest via Python-list: > >> I agree with everything you say. Especially the open source part. But > >> wouldn't you agree that .title() with all its arbitrary specificity to > >> appear in the very core of a general purpose language is quite

Re: Python cannot count apparently

2021-02-07 Thread Karsten Hilbert
Am Sun, Feb 07, 2021 at 07:47:03PM + schrieb Paul Bryan: > That's not the only problem with the code. There's a missing close- > paren and a reference to "string" which I presume was meant to be > "myString". I know. I wasn't going to spoil everything right away. The sort of response we would

Re: Python cannot count apparently

2021-02-07 Thread Karsten Hilbert
Am Sun, Feb 07, 2021 at 08:34:34PM +0100 schrieb Philipp Daher via Python-list: > I recently coded this snippet of code: > myString=„hello“ I doubt you have (coded *this* snippet of code) -- because those quotes wouldn't work. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B --

Re: open sentinel-2image python

2021-01-17 Thread Karsten Hilbert
Am Sun, Jan 17, 2021 at 02:20:24AM -0800 schrieb omid mohammadi: > When I open the sentinel-2 image in Python, I get the following error: > > MemoryError: Unable to allocate 115. MiB for an array with shape (5490, 5490) > and data type float32 > > How can I fix it? You can install more RAM. Kar

Aw: Re: Re: Re: How do you find what exceptions a class can throw?

2020-12-20 Thread Karsten Hilbert
> Trust me: it takes 100x getting anything done plus keep up with your prayers, > and it takes 100^100x learning anything solid, as in just forget about it. > Indeed, consider that we are rather going to the formal verification of > programs, software, and even hardware... I sincerly wish you

Aw: Re: Re: How do you find what exceptions a class can throw?

2020-12-20 Thread Karsten Hilbert
> > So what you are looking for is the form of a potential > > "timeout exception" (say, exception name) ? > > > > Provoke one and have a look. > > > > Then catch what you saw. > > > > Programmers don't guess... I did not suggest gue

Aw: Re: How do you find what exceptions a class can throw?

2020-12-20 Thread Karsten Hilbert
> > Remember, you get reporting (a traceback) and program cleanup and exit > > for free. What will catching an exception *add* to the user experience? > > If it's a timeout exception I'm going to delay a little while and then > try again. The timeout is probably because the server is busy. So wh

Re: Post request and encoding

2020-11-02 Thread Karsten Hilbert
On Mon, Nov 02, 2020 at 06:43:20PM +0100, Hernán De Angelis wrote: > I see, my mistake was (tacitly) assuming that encode() could work in place. > > Now I see that it should work in a previous line as you wrote. > > Thank you! Sure, and excuse my perhaps slightly terse tone in that earlier mail .

Re: Post request and encoding

2020-11-02 Thread Karsten Hilbert
On Mon, Nov 02, 2020 at 06:21:15PM +0100, Hernán De Angelis wrote: For the record: > Just reply to myself and whoever might find this useful. > > encode() must be done within the request call: Nope (but it can, as you showed). > header = {'Content-type':'application/xml', 'charset':'UTF-8'} > r

Aw: Re: Re: Python 3 how to convert a list of bytes objects to a list of strings?

2020-08-29 Thread Karsten Hilbert
> Just appending a message as a raw file to a mailbox, doesn't properly > add it as a new message. You need to add a From: line to the front, and > then go through the message and alter any line that begins as "From:" > (and possibly any line that begins with something like ">From:" or > ">>From:"

Aw: Re: Video file to subtitles file

2020-08-29 Thread Karsten Hilbert
> I want to extract subtitles from a MPEG video (which does not have any > previous subtitles) and then add them to the same video . I am not sure I parse the above: You want to *extract* subtitles from a video which *does not have* subtitles ? I have a feeling you will need to rephrase your obj

Aw: Re: Python 3 how to convert a list of bytes objects to a list of strings?

2020-08-29 Thread Karsten Hilbert
> However the problem appears to be that internally in Python 3 mailbox > class there is an assumption that it's being given 'ascii'. Do you really _need_ the mailbox class ? From what you've written so far my understanding was that you receive data (bytes) and want to append that to a file (which

Aw: Re: Python 3 how to convert a list of bytes objects to a list of strings?

2020-08-28 Thread Karsten Hilbert
> I want to transport the message into my mbox and Python 3 won't do it > without knowing how it's encoded whereas Python 2 just stuffed it in > there 'as is'. > > I want Python 3's mailbox class to juyst put what I tell it (even if > mis-formatted or mis-encoded) into the mbox. I guess using the

Aw: Re: Python 3 how to convert a list of bytes objects to a list of strings?

2020-08-28 Thread Karsten Hilbert
> > No interpreation requires, since parsing failed. Then you can start > > dealing with these exceptions. _Do not_ write unparsable messages into > > an mbox! > > > Maybe I shouldn't but Python 2 has been managing to do so for several > years without any issues. I am inclined to congratulate you

Aw: Re: Python 3 how to convert a list of bytes objects to a list of strings?

2020-08-28 Thread Karsten Hilbert
> >Are you sure you want `str()`? > > > str(b'aaa') > >"b'aaa'" > > > >Probably you want: > > > >map(lambda x: x.decode(), bbb) > > _And_ you need to know the encoding of the text in the bytes. The above > _assumes_ UTF-8 because that is the default for bytes.decode, and if > that is _not_ wha

Aw: Re: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Karsten Hilbert
> > > Because of this, the Python 3 str type is not suitable to store an email > > > message, since it insists on the string being Unicode encoded, > > > > I should greatly appreciate to be enlightened as to what > > a "string being Unicode encoded" is intended to say ? > > > > A Python 3 "str" or

Aw: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Karsten Hilbert
> Because of this, the Python 3 str type is not suitable to store an email > message, since it insists on the string being Unicode encoded, I should greatly appreciate to be enlightened as to what a "string being Unicode encoded" is intended to say ? Thanks, Karsten -- https://mail.python.org/ma

Aw: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Karsten Hilbert
> Terry Reedy wrote: > > On 8/26/2020 11:10 AM, Chris Green wrote: > > > > > I have a simple[ish] local mbox mail delivery module as follows:- > > ... > > > It has run faultlessly for many years under Python 2. I've now > > > changed the calling program to Python 3 and while it handles most > > >

  1   2   3   >