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

Make SrtFile Iterable #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Make SrtFile Iterable #63

wants to merge 1 commit into from

Conversation

cnbeining
Copy link

>>> for k,v in enumerate(subs):
...     print(v.text)
... 
blahblah
blahblah
blahblah
...

@byroot
Copy link
Owner

byroot commented Sep 14, 2016

Sorry but I don't understand:

  • SrtFile is already an iterable
  • __getitem__ is not to implement iteration, but for index based access of a sub element
  • __getitem__ is already implemented by the parent class (UserList).

What am I missing?

@cnbeining
Copy link
Author

It is quite weird that you can write something like

for i in srtfile:

But not

for k, v in enumerate(srtfile)

This quick patch will fix this problem.

2016年9月14日星期三,Jean Boussier notifications@github.com 写道:

Sorry but I don't understand:

  • SrtFile is already an iterable
  • getitem is not to implement iteration, but for index based
    access of a sub element
  • getitem is already implemented by the parent class (UserList).

What am I missing?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#63 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABfRgt4eaNqJFCW4pc3n_8nwb_K_D1Tmks5qp5xagaJpZM4J8Wk4
.

@byroot
Copy link
Owner

byroot commented Sep 14, 2016

You absolutely can use enumerate:

Not sure what your problem is, but it's not this.

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

Successfully merging this pull request may close these issues.

2 participants