Thank you, After reading the following documentations http://docs.python.org/tutorial/datastructures.html#looping-techniques http://docs.python.org/tutorial/controlflow.html#for-statements I ended up with this :
Version 3 : for i,row in d[:].iteritems() : # BUG : TypeError: unhashable type if len(row) < 2 : del d[i] Still buggy... Any lead for this error message? Is a slice unhashable? Am I looking in the right direction for this task? Mr. 427 Le vendredi 17 septembre 2010 à 20:50 -0400, bob gailer a écrit : > Please always reply-all so a copy goes to the tutor list. > > On 9/17/2010 6:20 PM, M. 427 wrote: > > Thank you very much for your answer. > > I wanted to know the pythonic way of doing this, so I did not post my > > buggy trial which was : > > > > version 1 : > > for row in d : > > if len(row) == 1 : > > del row # WRONG > > > > Version 2 : > > for i,row in d : > > if len(row) == 1 : > > del d(i) # BUG : Syntax error > > Thank you for posting code. In the future do so initially. It helps us > know where to help. > > It looks like you learned from version 1. > > When you get a syntax error check the manual. When you look at del in: > Python v2.6.4 documentation - The Python Standard Library - 6.8 > Mapping Type - dict > you will see d[key] - compare that to what you wrote in version 2. > > -- > Bob Gailer > 919-636-4239 > Chapel Hill NC _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor