Roger Gammans wrote: > def setColExpand(self, expand, colNum, proportion=0): > """ Sets the 'growable' status of one or more columns. """ > # If the colNum argument was passed first, switch it > # with the > # expand argument > if isinstance(expand, basestring): > expand, colNum = colNum, expand > if isinstance(colNum, (list, tuple)): > for col in colNum: > self.setColExpand(expand, col, proportion) > elif isinstance(colNum, basestring): > if colNum.lower() == "all": > for col in xrange(self.HighCol+1): > self.setColExpand(expand, col, proportion) > else: > raise ValueError( _("Invalid value passed for 'colNum' > parameter: '%s'. Only column numbers or the word 'all' are valid.") % colNum) > else: > curr = self.getColExpand(colNum) > self._colExpandState[colNum] = expand > if expand and not curr: > self.AddGrowableCol(colNum, proportion=proportion) > elif not expand and curr: > self.RemoveGrowableCol(colNum) > self.layout() > > My personal view is the first isinstance() eg, the test for tuple or > list is exactly what the article is complaining about. What you seem > to be trying to detect there is wether the colNum provides the > iteration interface, (eg. the __iter__() method) a client application > my so some reason use a custom opbject to store the columns.
True, we want to know if it is a sequence. > The tests for string are much more reasonable IMHO, although they > have there own issues with python3 (which has no basestring defined), > because there you really are testing for what an object is. We want to know if the object can store string data. > It is a difficult issue, and isinstance is a easy crutch to fall > into using , and I'm sure parts of my own code suffer from this > as well. Patches are welcome! :) Paul _______________________________________________ Post Messages to: Dabo-users@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/4ab38981.5070...@ulmcnett.com