Re: trouble building data structure

2014-09-29 Thread Ian Kelly
On Mon, Sep 29, 2014 at 7:52 AM, Steven D'Aprano wrote: > Whether you prefer to use setdefault, or a defaultdict, is a matter of > taste. There is potentially a significant difference in performance -- with setdefault, the subordinate data structure is created on every call to be passed into setd

Re: trouble building data structure

2014-09-29 Thread Steven D'Aprano
David Alban wrote: > greetings, > > i'm writing a program to scan a data file. from each line of the data > file > i'd like to add something like below to a dictionary. my perl background > makes me want python to autovivify, but when i do: > > file_data = {} > > [... as i loop th

Re: trouble building data structure

2014-09-28 Thread Ned Batchelder
On 9/28/14 8:04 PM, David Alban wrote: i'm writing a program to scan a data file. from each line of the data file i'd like to add something like below to a dictionary. my perl background makes me want python to autovivify, but when i do: file_data = {} [... as i loop through lin

Re: trouble building data structure

2014-09-28 Thread Chris Angelico
On Mon, Sep 29, 2014 at 10:04 AM, David Alban wrote: > file_data = {} > > [... as i loop through lines in the file ...] > > file_data[ md5sum ][ inode ] = { 'path' : path, 'size' : size, } > > what is the pythonic way to build my "file_data" data structure above that > has th

trouble building data structure

2014-09-28 Thread David Alban
greetings, i'm writing a program to scan a data file. from each line of the data file i'd like to add something like below to a dictionary. my perl background makes me want python to autovivify, but when i do: file_data = {} [... as i loop through lines in the file ...]