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-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-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-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 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 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-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: Correct syntax for pathological re.search()

2024-10-08 Thread Karsten Hilbert via Python-list
Am Tue, Oct 08, 2024 at 08:07:04PM +0100 schrieb MRAB via Python-list: > >unwanted_tex = '\sout{' > >if unwanted_tex not in line: do_something_with_libreoffice() > > > That should be: > > unwanted_tex = r'\sout{' Hm. Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux

Re: Correct syntax for pathological re.search()

2024-10-08 Thread Karsten Hilbert via Python-list
Am Mon, Oct 07, 2024 at 08:35:32AM -0500 schrieb Michael F. Stemper via Python-list: > I'm trying to discard lines that include the string "\sout{" (which is TeX, > for > those who are curious. I have tried: > if not re.search("\sout{", line): > if not re.search("\sout\{", line): > if not

Re: Correct syntax for pathological re.search()

2024-10-09 Thread Karsten Hilbert via Python-list
Am Tue, Oct 08, 2024 at 04:59:48PM -0400 schrieb Alan Bawden via Python-list: > Karsten Hilbert writes: > >Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux >Type "help", "copyright", "credits" or "license

Re: Best Practice Virtual Environment

2024-10-05 Thread Karsten Hilbert via Python-list
Am Sat, Oct 05, 2024 at 10:27:33PM +0200 schrieb Ulrich Goebel via Python-list: > Debian (or even Python3 itself) doesn't allow to pip install required > packages system wide, so I have to use virtual environments even there. But > is it right, that I have to do that for every single user? > > C

Re: Best Practice Virtual Environment

2024-10-06 Thread Karsten Hilbert via Python-list
Am Sun, Oct 06, 2024 at 12:21:09AM +0200 schrieb Karsten Hilbert via Python-list: > Am Sat, Oct 05, 2024 at 10:27:33PM +0200 schrieb Ulrich Goebel via > Python-list: > > > Debian (or even Python3 itself) doesn't allow to pip install required > > packages system wide

Re: FileNotFoundError thrown due to file name in file, rather than file itself

2024-11-12 Thread Karsten Hilbert via Python-list
Am Tue, Nov 12, 2024 at 09:52:31AM +0100 schrieb Loris Bennett via Python-list: > Regarding your example above, if 'missingfile.py' contains the following > > import configparser > > config = configparser.ConfigParser() > > try: > config.read('/foo/bar') > except FileNotFoundError as

Re: Using 'with open(...) as ...' together with configparser.ConfigParser.read

2024-10-31 Thread Karsten Hilbert via Python-list
Am Thu, Oct 31, 2024 at 07:47:17AM +0100 schrieb Loris Bennett via Python-list: > However I didn't make myself clear: I understand that there are > different functions, depending on whether I have a file name or a > stream. Nevertheless, I just can't think of a practical example where I > might j

<    1   2   3