0

What does this line mean in python code exactly this (,_)? this is a line to connect my PyQt UI with my python script

FROM_CLASS, _ = loadUiType(path.join(path.dirname(__file__), "car_Proj.ui"))

without this ,_ i got this error

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Qais Bsharat
  • 146
  • 3
  • 12

2 Answers2

1

As can be seen from the source code, loadUiType returns two objects: form_class and base_class. From your code, it seems you aren't interested in the base_class, so you name it _, which is a convention for "unimportant" variables. Alternatively, you could use:

FROM_CLASS = loadUiType(path.join(path.dirname(__file__), "car_Proj.ui"))[0]

See this answer for more information on the _ conventions in python

sacuL
  • 49,704
  • 8
  • 81
  • 106
0

It's actually pretty simple: when loadUiType returns two values but you want to store only one for later use, you can assign one to the dummy variable _. It also works with more than just two return values (_, my_var, _, _, _ = returns_five_values()).

linusg
  • 6,289
  • 4
  • 28
  • 78