Python Intermediate Tutorial 5 - Iterators & Generators

preview_player
Показать описание


If you like what you see be sure to subscribe and thumbs up!
Рекомендации по теме
Комментарии
Автор

for removing a class in vim, get the plugin called:
pythonobj and in normal mode do:
dac

itayel
Автор

if you're using python3 and getting:
TypeError: iter() returned non-iterator of type 'Reverse'
change the following:

def next(self):

to:

def __next__(self):

heshers
Автор

Akash Sarda Iterators return an element one by one, and so do generators. However a generator is a statement that generates an iterator for a single use in one line. eg. 
var = [int for int in intList if int == value2]

DrapsTV
Автор

You could also use string slicing to get the reversed string:

"teststring"[::-1] would result in a reversed string.

xParadiseLst
Автор

on the second iteration i got the error: SyntaxError: 'yield' outside function

roidrage
Автор

I got:
"Traceback (most recent call last):
  File Projects/reverse.py", line 46, in <module>
    Main()
  File Projects/reverse.py", line 42, in Main
    for char in rev:
TypeError: iter() returned non-iterator of type 'Reverse', " in two instances where I used my own typed copy of your code as well as the original code you've uploaded to the bin using Python 3.4.x on Mac OS X. Addendum: And that is after enclosing 'char' within parenthesis to update the code to 3.4.x standards.

JabbaTiure
Автор

Sometime at the 5th or 6th minute the video and the sound get synchronized :(  

stanislav
Автор

So generators give the element one by one right? so Range is a generator?

akash