[_] Python Question
Daniel Hilton
daniel.hilton at gmail.com
Thu Dec 17 16:10:10 GMT 2009
2009/12/17 Andy Gale <andy at mentalist.co.uk>: > Hi _, > > I know there's a few Python goons on here so... is there a better way > of doing this in Python? > > attributes = {} > > attribute_data = mark.fetchall() > > for i in attribute_data: > > if i[1] in attributes: > attributes[i[1]].append(i[0]) > else: > attributes[i[1]] = [i[0]] > > Given my experience with Python so far, there is probably some epic > shortcut for doing this. Does mark.fetchall() return a list? Cheers, Dan > > Cheers, > > Andy > -- > Andy Gale > W: andy-gale.com > T: http://twitter.com/andygale > > -- > underscore_ list info/archive -> http://www.under-score.org.uk/mailman/listinfo/underscore > -- Dan Hilton ============================ www.twitter.com/danhilton www.DanHilton.co.uk ============================