Drive
Drive Class Documentation
Represents a single drive within a sports event.
A drive typically consists of a sequence of plays executed by the offensive team, and may result in a score, turnover, or punt. This class handles loading and structuring that information from the ESPN API response.
Attributes:
Name | Type | Description |
---|---|---|
drive_json |
dict
|
Raw JSON data for the drive. |
espn_instance |
PYESPN
|
The ESPN API interface instance. |
event_instance |
Event
|
The parent event this drive belongs to. |
plays |
list[Play]
|
List of Play objects associated with this drive. |
description |
str
|
Summary of the drive. |
id |
str
|
Unique drive identifier. |
sequence_number |
int
|
Order of the drive within the event. |
ref |
str
|
API reference URL to this drive. |
start |
dict
|
Metadata about how the drive started. |
end |
dict
|
Metadata about how the drive ended. |
time_elapsed |
dict
|
Duration of the drive. |
yards |
int
|
Total yardage gained during the drive. |
is_score |
bool
|
Whether the drive resulted in a score. |
offensive_plays |
int
|
Number of offensive plays run during the drive. |
result |
str
|
Raw result string (e.g., 'Touchdown', 'Punt'). |
result_display |
str
|
Formatted display result. |
team |
Team
|
Team that had possession during the drive. |
end_team |
Team
|
Team that was on defense at the end of the drive. |
plays_ref |
str
|
API reference to the list of plays in this drive. |
Source code in pyespn/classes/gamelog.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
espn_instance
property
PYESPN: the espn client instance associated with the class
plays
property
list[Play]: a list of plays for the drive
__init__(drive_json, espn_instance, event_instance)
Initializes a Drive instance using the provided drive JSON.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
drive_json
|
dict
|
JSON representation of the drive. |
required |
espn_instance
|
PYESPN
|
The ESPN API interface instance. |
required |
event_instance
|
Event
|
The event this drive belongs to. |
required |
Source code in pyespn/classes/gamelog.py
__repr__()
Returns a human-readable string representation of the Drive instance.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A formatted string in the form " |
Source code in pyespn/classes/gamelog.py
to_dict()
Converts the Drive instance to its original JSON dictionary.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The drives's raw JSON data. |