Re: [Tutor] Dict of Dict with lists

2018-04-26 Thread Neil Cerutti
On 2018-04-26, Alan Gauld via Tutor wrote: > OTOH its definitely not good OOP, ther are no methods and we > are just using the class as a record. (A named tuple might > actually be a better option on reflection.) namedtuple is great in lots of cases, but sometimes it transpires I wish to make alt

Re: [Tutor] Dict of Dict with lists

2018-04-26 Thread Alan Gauld via Tutor
On 26/04/18 14:48, Mats Wichmann wrote: >>> However personally I'd use a class to define your data structure and >>> just have a top level dictionary holding instances of the class. >> >> You are right (again). I haven't thougt of using classes, but that's exactly >> what they were invented for. T

Re: [Tutor] Dict of Dict with lists

2018-04-26 Thread Mats Wichmann
On 04/25/2018 12:46 PM, Kai Bojens wrote: > On 25/04/2018 –– 18:35:30PM +0100, Alan Gauld via Tutor wrote: >>> ... >>> for line in logfile: >>> result = pattern.search(line) > >> Doesn't this overwrite your data structure? >> I would strongly advise using another name. > > You are of

Re: [Tutor] Dict of Dict with lists

2018-04-25 Thread Kai Bojens
On 25/04/2018 –– 18:35:30PM +0100, Alan Gauld via Tutor wrote: > > ... > > for line in logfile: > > result = pattern.search(line) > Doesn't this overwrite your data structure? > I would strongly advise using another name. You are of course right. I accidentally shortened this name as

Re: [Tutor] Dict of Dict with lists

2018-04-25 Thread Alan Gauld via Tutor
On 25/04/18 14:22, Kai Bojens wrote: > The structure I'd like to have: > > result = { > 'f...@bar.de': { > 'Countries': [DE,DK,UK] > 'IP': ['192.168.1.1','172.10.10.10'] > 'Count': [12] > } > } > ... > for line in logfile: >