Package nflgame :: Module game :: Class Game
[frames] | no frames]

Class Game

source code

object --+
         |
        Game

Game represents a single pre- or regular-season game. It provides a window into the statistics of every player that played into the game, along with the winner of the game, the score and a list of all the scoring plays.

Instance Methods
 
__init__(self, eid=None, fpath=None)
Creates a new Game instance given a game identifier.
source code
 
is_home(self, team)
Returns true if team (i.e., 'NE') is the home team.
source code
 
season(self)
Returns the year of the season this game belongs to.
source code
 
game_over(self)
game_over returns true if the game is no longer being played.
source code
 
playing(self)
playing returns true if the game is currently being played.
source code
 
save(self, fpath=None)
Save the JSON data to fpath.
source code
 
nice_score(self)
Returns a string of the score of the game.
source code
 
max_player_stats(self)
Returns a GenPlayers sequence of player statistics that combines game statistics and play statistics by taking the max value of each corresponding statistic.
source code
 
__getattr__(self, name) source code
 
__sub__(self, other) source code
 
__str__(self)
str(x)
source code

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

Static Methods
a new object with type S, a subtype of T
__new__(cls, eid=None, fpath=None) source code
Properties

Inherited from object: __class__

Method Details

__new__(cls, eid=None, fpath=None)
Static Method

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

__init__(self, eid=None, fpath=None)
(Constructor)

source code 

Creates a new Game instance given a game identifier.

The game identifier is used by NFL.com's GameCenter live update web pages. It is used to construct a URL to download JSON data for the game.

If the game has been completed, the JSON data will be cached to disk so that subsequent accesses will not re-download the data but instead read it from disk.

When the JSON data is written to disk, it is compressed using gzip.

Overrides: object.__init__

save(self, fpath=None)

source code 

Save the JSON data to fpath. This is done automatically if the game is over.

nice_score(self)

source code 

Returns a string of the score of the game. e.g., "NE (32) vs. NYG (0)".

max_player_stats(self)

source code 

Returns a GenPlayers sequence of player statistics that combines game statistics and play statistics by taking the max value of each corresponding statistic.

This is useful when accuracy is desirable. Namely, using only play-by-play data or using only game statistics can be unreliable. That is, both are inconsistently correct.

Taking the max values of each statistic reduces the chance of being wrong (particularly for stats that are in both play-by-play data and game statistics), but does not eliminate them.

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)