Python giving UnicodeWarning when calling remove() on a list containing unicode strings

I have two lists containing unicode strings. I'm trying to remove every element from availablesongs that also appears in recentsongs.

The following code is causing the problem (exception clause commented out for debugging):

for x in recentsongs:
    #except ValueError:
    #   pass

This code works fine when the lists contain ASCII-only strings, but when characters from other languages are introduced, it fails:

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
ValueError: list.remove(x): x not in list

The error is coming from the remove() function itself, which has me stumped. How can I work around this?


What I would do:


os.listdir() was causing some of my problems because it sometimes returns unicode strings and sometimes doesn't. The function to_unicode_or_bust works to fix the rest of it.

Need Your Help

Efficient evaluation of hypergeometric functions

algorithm math numerical

Does anyone have experience with algorithms for evaluating hypergeometric functions? I would be interested in general references, but I'll describe my particular problem in case someone has dealt ...

Moving to generics .

c# winforms generics

I am migrating a 1.1 winforms app to 2.0. what are the main things i should immediately change because of generics. Here what i have so far: