Skip to main content
deleted 82 characters in body; edited tags; edited title
Source Link
user4157124
  • 3k
  • 21
  • 33
  • 48

Python class Class accessible by iterator and index

Might be a n00b question, but I currently have aMy class that implements an iterator so I can do something like:

for i in class():

butBut I want to be able to access the class by index as well like:

class()[1]

How can I do that?

Thanks!

Python class accessible by iterator and index

Might be a n00b question, but I currently have a class that implements an iterator so I can do something like

for i in class():

but I want to be able to access the class by index as well like

class()[1]

How can I do that?

Thanks!

Class accessible by iterator and index

My class implements an iterator so I can do:

for i in class():

But I want to be able to access the class by index as well:

class()[1]

How can I do that?

Source Link
xster
  • 6.7k
  • 9
  • 58
  • 63

Python class accessible by iterator and index

Might be a n00b question, but I currently have a class that implements an iterator so I can do something like

for i in class():

but I want to be able to access the class by index as well like

class()[1]

How can I do that?

Thanks!