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
24 2:56 AM To: python-list@python.org Subject: Re: Popping key causes dict derived from object to revert to object 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 t

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

2024-03-25 Thread AVI GROSS via Python-list
ython-list@python.org Subject: Re: Popping key causes dict derived from object to revert to object 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 > s

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

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