Is it possible to unpack a tuple in Python without creating unwanted variables? -
is there way write following function ide doesn't complain column unused variable?
def get_selected_index(self):     (path, column) = self._tree_view.get_cursor()     return path[0]   in case don't care second item in tuple , want discard reference when unpacked.
in python _ used ignored placeholder.
(path, _) = self._treeview.get_cursor()   you avoid unpacking tuple indexable.
def get_selected_index(self):     return self._treeview.get_cursor()[0][0]      
Comments
Post a Comment