Package nflgame :: Module player :: Class Player
[frames] | no frames]

Class Player

source code

object --+
         |
        Player

Player represents a single player and all of his statistical categories for a single game. Every player has 'playerid', 'name' and 'home' fields. Additionally, depending upon which statistical categories that player was involved in for the game, he'll have properties such as 'passing_tds', 'rushing_yds', 'defense_int' and 'kicking_fgm'.

In order to know whether a paricular player belongs to a statical category, you may use the filtering methods of a Players sequence or alternatively, use the 'passing', 'rushing', 'kicking', etc., boolean members of this class.

You may also inspect whether a player has a certain property by using the special __dict__ attribute. For example:

   if 'passing_yds' in player.__dict__:
       # Do something with player.passing_yds
Instance Methods
 
__init__(self, playerid, name, home)
Create a new Player instance with the player id (from NFL.com's GameCenter), the player's name (e.g., "T.Brady") and whether the player is playing in a home game or not.
source code
 
all_stats(self)
Returns a dict of all stats for the player.
source code
 
formatted_stats(self)
Returns a roughly-formatted string of all statistics for this player.
source code
 
__str__(self)
Simply returns the player's name, e.g., "T.Brady".
source code
 
__add__(self, player)
Adds two players together.
source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, playerid, name, home)
(Constructor)

source code 

Create a new Player instance with the player id (from NFL.com's GameCenter), the player's name (e.g., "T.Brady") and whether the player is playing in a home game or not.

Overrides: object.__init__

all_stats(self)

source code 

Returns a dict of all stats for the player. Each key is a statistical category corresponding to a dict with keys corresponding to each statistic and values corresponding to each statistic's value.

__str__(self)
(Informal representation operator)

source code 

Simply returns the player's name, e.g., "T.Brady".

Overrides: object.__str__

__add__(self, player)
(Addition operator)

source code 

Adds two players together. Only two player objects that correspond to the same human (i.e., GameCenter identifier) can be added together.

If two different players are added together, an assertion will be raised.

The effect of adding two player objects simply corresponds to the sums of all statistical values.

Note that as soon as two players have been added, the 'home' property becomes undefined.