problem with interface of operator.itemgetter

2009-08-13 Thread dou dou
I have a function to do some thing like LEFT JOIN in SQL, the function use the itemgetter to get the "ON" and "SELECT" parameters of the two table(list of list), the problem is that itemgetter may return a value or a tuple of values, because of the inconsistent return type of itemgetter, I have to

Re: problem with interface of operator.itemgetter

2009-08-18 Thread dou dou
2009/8/17 Simon Forman > You can use a little helper function to create your itemgetter like this: > > def makeItemGetter(indexes): >I = itemgetter(*indexes) >if len(indexes) > 1: >return I >return lambda thing: (I(thing),) > > If indexes contains only one index the itemgette