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

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -