Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlayPlayer's as_player() function not working as expected #172

Closed
ryantuck opened this issue Aug 16, 2016 · 2 comments
Closed

PlayPlayer's as_player() function not working as expected #172

ryantuck opened this issue Aug 16, 2016 · 2 comments

Comments

@ryantuck
Copy link

q_brady = nfldb.Query(db)
q_brady.game(season_year=2015, season_type='Regular', week=1)
q_brady.player(full_name='Tom Brady')
for pp in q_brady.as_play_players():
    print pp.player()

yields:

Traceback (most recent call last):
  File "test.py", line 21, in <module>
    print x.player()
TypeError: 'Player' object is not callable

and from the source code in nfldb/types.py:

    @property
    def player(self):
        """
        The `nfldb.Player` object that this "play player"
        corresponds to. The player is retrieved from the database if
        necessary.
        """
        if self._player is None:
            self._player = Player.from_id(self._db, self.player_id)
        return self._player

Should this function be leveraging a query to return this player? Or calling a blank Player().from_id(...) constructor? Or am I just doing something wrong?

@ochawkeye
Copy link
Contributor

The @property decorator changes the syntax of that attribute. I think you'll find print pp.player instead of print pp.player() as a function call will spit out what you're trying to obtain.

@ryantuck
Copy link
Author

@ochawkeye that indeed did it. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants