On Apr 29, Jesper Noehr <[EMAIL PROTECTED]> wrote:

> I'm experiencing something weird here. Here's some sample code:

Your code is equivalent to:

    from imdb import IMDb
    i = IMDb('sql', uri=[...snip...])
    search_result = i.search_movie("Land of the Tiger")

    for movie in search_result:
        i.update(movie)
        print search_result[1]["title"], search_result[1].movieID

As you can see from the above simpler code it's normal that every
iteration of the loop prints the same movie, specifically the
second item of the search_result list (I've added
search_result[1].movieID to show that the movieID of the printed
title doesn't change).
Obviously it's probably not what you wanted to achieve; I suppose
the last line should be:
  print movie['title'], movie.movieID

If you're wondering why the title of the second movie in the
search_result list changes after the first iteration, the answer
is a bit more tricky, and it's caused by the call to i.update(movie).
When you search for a movie title, both the list of titles and the
list of AKAs are scanned (they are in the 'title' and 'aka_title'
tables of the database); it's assumed that the user needs the matched
title - original or AKA - to remind him what he was searching for.

So, if you search for "Land of the Tiger" the second item in the
results list happens to be "Land of the Nile", but this is just
an AKA for "Ard el Nil" - a '46 Egyptian movie that I'm sure is
worth renting. :-)
Calling i.update(movie) on this title, however, will cause the
'title' key to be replaced with the original title, while the
searched title can be found in the 'akas' key.
If for some reason you need to keep the title matched by the
search, you need to store it in a variable in your code.


I hope this is clear, despite my poor English.
-- 
Davide Alberani <[EMAIL PROTECTED]> [PGP KeyID: 0x465BFD47]
http://erlug.linux.it/~da/

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Imdbpy-devel mailing list
Imdbpy-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-devel

Reply via email to