Re: How to turn a defaultdict into a normal dict.

2020-06-16 Thread Matt Wheeler
On Wed, 10 Jun 2020 at 23:02, Peter Otten <__pete...@web.de> wrote: > > However later when I actually use it, accessing a key that is not > > present, should raise KeyError. > > > > Is that somehow possible? > > It never occured to me to try that, but: > > >>> from collections import defaultdict >

Re: How to turn a defaultdict into a normal dict.

2020-06-10 Thread Peter Otten
Antoon Pardon wrote: > The problem I face is that at the building face, I need a defaultdict > because the values are lists that are appended too. So a > defaultdict(list) is convenient in that new entries are treated as if > the value is an empty list. > > However later when I actually use it, a

Re: How to turn a defaultdict into a normal dict.

2020-06-10 Thread MRAB
On 2020-06-10 09:05, Antoon Pardon wrote: The problem I face is that at the building face, I need a defaultdict because the values are lists that are appended too. So a defaultdict(list) is convenient in that new entries are treated as if the value is an empty list. However later when I actually

How to turn a defaultdict into a normal dict.

2020-06-10 Thread Antoon Pardon
The problem I face is that at the building face, I need a defaultdict because the values are lists that are appended too. So a defaultdict(list) is convenient in that new entries are treated as if the value is an empty list. However later when I actually use it, accessing a key that is not pre