Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: '<' not supported between instances of 'NoneType' and 'str'

I"m getting this error as I try to make a ttk.Combobox using the values of a set that I select from a .db file.

for row in self.sql.execute("SELECT {0} FROM Songinfo".format(self.variable1.get())):
        self.List2.append(row)
        self.seen.add(row)
self.Option2 = ttk.Combobox(self, values=sorted(self.seen), textvariable=self.variable2)
self.Option2.grid(row=3, column=1)

self.seen, when printed out returns something like:

{('Heavy Metal',), ('Soundtrack',), ('Pop/Rock',), ('Metal',), 
 ('Alternative',), ('Alternative & Punk',), ('Rock',),
 ('Pop',), ('Classical Crossover',), (None,)}

this is a set of genres. I'm getting that error and I'm not sure why, it wasn't an issue till recently, any help is appreciated, thanks.

like image 689
Matthew Oujiri Avatar asked Jun 12 '18 22:06

Matthew Oujiri


2 Answers

Remove the offending tuple from your set:

self.seen = {x for x in self.seen if x[0] is not None}
like image 94
DYZ Avatar answered Oct 30 '22 07:10

DYZ


sorted(self.seen) is going to use < by default. You can supply a cmp or key function if you don't want that.

like image 41
Aaron Bentley Avatar answered Oct 30 '22 07:10

Aaron Bentley