On Mar 24, michael charclo <charclo.mich...@gmail.com> wrote: > I'm using version 3.6 because it's standard in ubuntu 8.10 and > that's probably what most of the users of my program will be using.
I understand, but the IMDb web server is a moving target, and 'http' and 'mobile' need to be constantly updated. > Since which version doesn't this work anymore: title = > serie['episodes'][1][4]['title'] ? >From a fast test, I can see that it works with 3.8. It goes without saying that "the latest, the greatest", so your users should really consider upgrading to IMDbPY 4.0. :-) The Debian package, courtesy of Ana Beatriz Guerrero López, is always up-to-date in unstable. I don't know if it can be installed in Ubuntu. > Since which version can I use sortedSeasons and sortedEpisodes? 3.8 > or 4.0? They are available since 2.5. > For getting the title I then would do title = > serie.get('episodes').get(1).get(4).get('title') and it will return > None if the title isn't available? Provided that at least 'title' should really be always present (I was thinking more about 'plot'), your solution is a bit too much one-liner for my Italian well-educated taste. ;-) And, by the way, won't work. :-) serie.get('episodes') will return None is there's no 'episodes' key (and this _can_ happen), and None doesn't have a "get" method - and so your code will explode anyway. :-) A working variation: serie.get('episodes', {}).get(1, {}).get(4, {}).get('title') were every "get" method sets its default return value to an empty dictionary (which, in turn, provides a "get" method). Honestly, I don't like it at all; in these cases it's much better to work one step at a time; something like: episodes = serie.get('episodes') if episodes: ... The functions in the helpers module could ease you writing cleaner code: for episode in helpers.sortedEpisodes(serie): title = episode['title'] plot = episode.get('plot') if plot: .... Or, if you prefer: for season in helpers.sortedSeasons(serie): for episode in helpers.sortedEpisodes(serie, season=season): title = episode['title'] plot = episode.get('plot') if plot: .... HTH, -- Davide Alberani <davide.alber...@gmail.com> [PGP KeyID: 0x465BFD47] http://erlug.linux.it/~da/ ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ Imdbpy-devel mailing list Imdbpy-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/imdbpy-devel