Package moviestat :: Module top_movies :: Class TopMovies
[hide private]
[frames] | no frames]

Class TopMovies

object --+
         |
        TopMovies

The class TopMovies represents charts of top-rated movies in a movie database (such as IMDB.com). A TopMovies object can be queried about various statistics through its methods. E.g. "What is the highest-rated movie?", "What is the highest-rated movie made between 1960 and 1969?", "How many movies from 1980 are in the chart?"

Instance Methods [hide private]
 
__init__(self, file_name=None)
Creates a new TopMovies object.
int
get_size(self)
Returns the size of the top movies chart.
movie object
get_Nth(self, n)
Returns the 'Nth' movie in the chart.
movie object
get_best(self)
Returns the highest-rated movie in the chart.
int
get_position(self, movie)
Returns the position that a given movie occupies in the top movies chart.
int
get_year_count(self, year)
Returns the number of movies that appear in the top movies chart and are from the given year.
movie object
get_best_of_interval(self, start, end)
Returns the movie which has the highest rating of all movies made between the two given years.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, file_name=None)
(Constructor)

 

Creates a new TopMovies object. An object created this way uses an IMDB.com "Top 250 Movies of All-Time" chart (as voted by website visitors dated August, 2006) as its database.

Overrides: object.__init__

get_size(self)

 

Returns the size of the top movies chart. That is, returns the number of movies in the chart.

Returns: int
chart size

get_Nth(self, n)

 

Returns the 'Nth' movie in the chart. That is, given a number n, returns the movie which occupies that position in the chart. For instance, calling get_Nth(4) returns the movie with the fourth highest rating.

Parameters:
  • n - a positive number between 1 and chart size
Returns: movie object
the Nth movie in the chart

get_best(self)

 

Returns the highest-rated movie in the chart. Calling this method is equivalent to calling get_Nth(1)

Returns: movie object
the best movie, wrt. rating

get_position(self, movie)

 

Returns the position that a given movie occupies in the top movies chart.

Parameters:
  • movie (movie object) - a movie whose chart position is to be determined
Returns: int
the given movie's position (a positive integer between 1 and chart size) or a negative number if the given movie does not appear in the chart

get_year_count(self, year)

 

Returns the number of movies that appear in the top movies chart and are from the given year.

Parameters:
  • year - the number of any year
Returns: int
the number of movies from the given year that appear in the chart

get_best_of_interval(self, start, end)

 

Returns the movie which has the highest rating of all movies made between the two given years. For instance, get_best_of_interval(1900, 1940) returns the highest-rated movie made no earlier than 1900 and no later than 1940.

Parameters:
  • start - start year (included in interval)
  • end - end year (included in interval)
Returns: movie object
the highest-rated movie in the given interval