Re: Why x+=1 doesn't return x value instead of an object

2020-10-30 Thread Jon Ribbens via Python-list
On 2020-10-31, Stefan Ram wrote: > Siddhharth Choudhary writes: >>I want to know why x+=1 does not return the value of the variable. > > Which value? The old or the new one? > > Expressions never return values. Except when they're assignment expressions, when they do. -- https://mail.python

Re: Why x+=1 doesn't return x value instead of an object

2020-10-30 Thread Jon Ribbens via Python-list
On 2020-10-31, Chris Angelico wrote: > On Sat, Oct 31, 2020 at 1:51 PM Jon Ribbens via Python-list > wrote: >> >> On 2020-10-31, Stefan Ram wrote: >> > Siddhharth Choudhary writes: >> >>I want to know why x+=1 does not return the value of the variable.

Re: Letter replacer - suggestions?

2020-12-07 Thread Jon Ribbens via Python-list
On 2020-12-07, Chris Angelico wrote: > On Tue, Dec 8, 2020 at 6:41 AM Grant Edwards > wrote: >> On 2020-12-07, MRAB wrote: >> > Avoid a 'bare' except unless you _really_ mean it, which is >> > virtually never. Catch only those exceptions that you're going to >> > handle. >> >> And sometimes "ha

Re: How to enter multiple, similar, dictionaries?

2023-12-11 Thread Jon Ribbens via Python-list
On 2023-12-11, Chris Green wrote: > Chris Green wrote: >> Is there a way to abbreviate the following code somehow? >> >> lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'} >> sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'} >> la = {'dev':'bbb', 'input':'2', 'name':'Leisu

Re: Await expressions (Posting On Python-List Prohibited)

2024-02-02 Thread Jon Ribbens via Python-list
On 2024-02-02, Lawrence D'Oliveiro wrote: > On 1 Feb 2024 10:09:10 GMT, Stefan Ram wrote: > >> Heck, even of the respected members of this newsgroup, IIRC, no one >> mentioned "__await__". > > It’s part of the definition of an “awaitable”, if you had looked that up. > >

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

Re: Timezone in HH:MM Format

2024-06-18 Thread Jon Ribbens via Python-list
On 2024-06-18, Ivan "Rambius" Ivanov wrote: > Hello, > > How can I convert a date, usually datetime.now(), into a format where > the timezone is in hours:minutes format. I was able to get that format > in shell: > > $ date +%Y-%m-%dT%H:%M:%S%:z > 2024-06-18T19:24:09-04:00 > > The closest I got in

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

2024-09-09 Thread Jon Ribbens via Python-list
On 2024-09-08, Greg Ewing wrote: > On 8/09/24 9:20 am, Karsten Hilbert wrote: >> try: >> do something >> except: >> log something >> finally: >> .commit() >> >> cadence is fairly Pythonic and elegant in that it ensures the >> the .commit() wil

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

2024-09-09 Thread Jon Ribbens via Python-list
On 2024-09-09, Lawrence D'Oliveiro wrote: > On Mon, 9 Sep 2024 09:13:40 - (UTC), Jon Ribbens wrote: >> On 2024-09-08, Lawrence D'Oliveiro wrote: >>> On Sun, 8 Sep 2024 11:03:21 - (UTC), Jon Ribbens wrote: >>>> What if there's an exc

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

2024-09-09 Thread Jon Ribbens via Python-list
On 2024-09-08, Lawrence D'Oliveiro wrote: > On Sun, 8 Sep 2024 11:03:21 - (UTC), Jon Ribbens wrote: >> What if there's an exception in your exception handler? I'd put the >> rollback in the 'finally' handler, so it's always called. If you've

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

2024-09-09 Thread Jon Ribbens via Python-list
On 2024-09-09, Karsten Hilbert wrote: > 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. Th

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

2024-09-09 Thread Jon Ribbens via Python-list
On 2024-09-09, Lawrence D'Oliveiro wrote: > On Mon, 9 Sep 2024 10:00:11 - (UTC), Jon Ribbens wrote: >> On 2024-09-09, Lawrence D'Oliveiro wrote: >>> The database only needs to commit when it is explicitly told. Anything >>> less -- no commit. >>

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

2024-09-10 Thread Jon Ribbens via Python-list
On 2024-09-09, Lawrence D'Oliveiro wrote: > On Mon, 9 Sep 2024 21:12:51 - (UTC), Jon Ribbens wrote: >> On 2024-09-09, Lawrence D'Oliveiro wrote: >>> On Mon, 9 Sep 2024 10:00:11 - (UTC), Jon Ribbens wrote: >>>> On 2024-09-09, Lawrence D'Oliv

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

2024-09-10 Thread Jon Ribbens via Python-list
On 2024-09-10, Karsten Hilbert wrote: > 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 pos

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

2024-09-10 Thread Jon Ribbens via Python-list
On 2024-09-10, Lawrence D'Oliveiro wrote: > On Tue, 10 Sep 2024 08:38:30 - (UTC), Jon Ribbens wrote: > >> On 2024-09-09, Lawrence D'Oliveiro wrote: >>> >>> On Mon, 9 Sep 2024 21:12:51 - (UTC), Jon Ribbens wrote: >>>> >>>>

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

2024-09-11 Thread Jon Ribbens via Python-list
On 2024-09-11, Lawrence D'Oliveiro wrote: > On Tue, 10 Sep 2024 22:48:36 - (UTC), Jon Ribbens wrote: >> But what if you tell it the wrong thing ... > > To get back to the original point of this thread, all that rigmarole to > try to ensure to call “rollback” in

Re: Correct syntax for pathological re.search()

2024-10-08 Thread Jon Ribbens via Python-list
On 2024-10-07, Stefan Ram wrote: > "Michael F. Stemper" wrote or quoted: >>For now, I'll use the "r" in a cargo-cult fashion, until I decide which >>syntax I prefer. (Is there any reason that one or the other is preferable?) > > I'd totally go with the r-style notation! > > It's got one bumme

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

2024-10-29 Thread Jon Ribbens via Python-list
On 2024-10-29, Loris Bennett wrote: > Hi, > > With Python 3.9.18, if I do > > try: > with open(args.config_file, 'r') as config_file: > config = configparser.ConfigParser() > config.read(config_file) > print(config.sections()) > > i.e try to read the

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

2024-10-30 Thread Jon Ribbens via Python-list
On 2024-10-30, Loris Bennett wrote: > Jon Ribbens writes: >> As per the docs you link to, the read() method only takes filename(s) >> as arguments, if you have an already-open file you want to read then >> you should use the read_file() method instead. > > As you

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

2024-10-30 Thread Jon Ribbens via Python-list
On 2024-10-30, Loris Bennett wrote: > Jon Ribbens writes: >> On 2024-10-30, Loris Bennett wrote: >>> Jon Ribbens writes: >>>> As per the docs you link to, the read() method only takes filename(s) >>>> as arguments, if you have an already-open file you

Re: Printing UTF-8 mail to terminal

2024-11-02 Thread Jon Ribbens via Python-list
On 2024-11-01, Eli the Bearded <*@eli.users.panix.com> wrote: > In comp.lang.python, Gilmeh Serda wrote: >> Python 3.12.6 (main, Sep 8 2024, 13:18:56) [GCC 14.2.1 20240805] on linux >> Type "help", "copyright", "credits" or "license" for more information. >> >>> help('modules') >> >> Please wai

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

2024-10-31 Thread Jon Ribbens via Python-list
On 2024-10-31, Loris Bennett wrote: > Jon Ribbens writes: >> On 2024-10-30, Loris Bennett wrote: >>> Jon Ribbens writes: >>>> On 2024-10-30, Loris Bennett wrote: >>>>> Jon Ribbens writes: >>>>>> As per the docs you link to, the r

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

2024-11-14 Thread Jon Ribbens via Python-list
On 2024-11-14, Michael Torrie wrote: > On 11/14/24 12:03 AM, Left Right wrote: >>> On any Unix system this is untrue. Rotating a log file is quite simple: >> >> I realized I posted this without cc'ing the list: >> http://jdebp.info/FGA/do-not-use-logrotate.html . >> >> The link above gives a mo

<    8   9   10   11   12   13