On Saturday, May 10, 2014 9:22:43 AM UTC+8, eckh...@gmail.com wrote: > I'm migrating from Perl to Python and unable to identify the equivalent of > key of key concept. The following codes run well, > > > > import csv > > > > > attr = {} > > > > > > with open('test.txt','rb') as tsvin: > > > tsvin = csv.reader(tsvin, delimiter='\t') > > > > > > for row in tsvin: > > > ID = row[1] > > > > > > > until: > > attr[ID]['adm3'] = row[2] > > > > I then try: > > attr[ID].adm3 = row[2] > > > > still doesn't work. Some posts suggest using module dict but some do not. I'm > a bit confused now. Any suggestions?
Please check your attr as an empty dictionary or so-called a hash in perl. The syntax of adding a (K,V) pair is different between python and perl. -- https://mail.python.org/mailman/listinfo/python-list