Please type example code that produces the issue:
import pylast
network = pylast.get_lastfm_network(api_key = "(KEY)", api_secret = "(KEY)")
# Both rask00 and radio_head247 have RADIOHEAD as top artist
radiohead_1 = network.get_user("rask00").get_top_artists()[0].item
radiohead_2 = network.get_user("radio_head247").get_top_artists()[0].item
# Therefore the following statement correctly returns TRUE
radiohead_1 == radiohead_2
# But the following statement does not work correctly:
set([radiohead_1, radiohead_2])
What is the expected output? What do you see instead?
It is supposed to show set([Radiohead]), while it shows set([Radiohead,
Radiohead])
What version of pyLast is this?
0.4.13
Please provide any additional information below.
The solution to this bug is to add a function __hash__ to the class Artist and
the other related
classes. The reason is explained here:
http://wiki.python.org/moin/DictionaryKeys
Since __eq__ and __ne__ are already defined in Artist using the artist's name,
then the solution is
to add the following code to the class Artist:
def __hash__(self):
return hash(self.get_name().lower())
and do the same on the other related classes (Album, etc...)
Original issue reported on code.google.com by claud...@gmail.com on 6 Oct 2009 at 2:11
Original issue reported on code.google.com by
claud...@gmail.com
on 6 Oct 2009 at 2:11