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

Use reversed() instead of this weird inverted manual for loop stuff #22

Open
rpdelaney opened this issue Nov 15, 2018 · 3 comments
Open

Comments

@rpdelaney
Copy link
Collaborator

rpdelaney commented Nov 15, 2018

This is one of those "what was I thinking?" moments now that I've had some time to level up my python since I wrote this.

@rpdelaney
Copy link
Collaborator Author

rpdelaney commented Nov 15, 2018

Might require changes to python-chess.

https:/docs.python.org/3/library/functions.html#reversed

reversed(seq)

    Return a reverse iterator. seq must be an object which has 
a __reversed__() method or supports the sequence protocol 
(the __len__() method and the __getitem__() method with integer 
arguments starting at 0).

@rpdelaney
Copy link
Collaborator Author

Consider extending with a superclass also, in the event that python-chess can't be changed.

@rpdelaney
Copy link
Collaborator Author

rpdelaney commented Dec 10, 2018

niklasf/python-chess/issues/319 enabled use of reversed(node.mainline()): node.mainline() now returns an iterator of GameNodes, not Moves, and .mainline() supports the sequence protocol.

@rpdelaney rpdelaney self-assigned this Dec 10, 2018
@rpdelaney rpdelaney removed their assignment Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant