Skip to content

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 [email protected] 写道:

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