This is from page 204 of Python for Data Analysis by Wes Mckinney
genre_iter = (set(x.split('|')) for x in movies.genres)
genres = sorted(set.union(*genre_iter))
This code works perfectly when using the %paste
method in IPython. The code also works perfectly when run in Python shell. However, when I type the second line into IPython directly, without the %paste
method
genres = sorted(set.union(*genre_iter))
I get the following error
TypeError: descriptor 'union' of 'set' object needs an argument
this appears to be a bug, unless there is a feature of IPython that I am still unaware of.