My Coding >
Programming language >
Python >
Python Generators
Python Generators (Page: 2)Go to Page: Generator expressions in PythonGenerator expressions are generator version for list comprehensions, but return generator instead of list.
It is important to understand, that this generator will only be executed when it will be used, and after its iterator will be pointed to the end of its generating values
One more example of usage of this 10 squares generator
List of pythogorian triplets with generatorsVery simple task is to find N pythogorian triplets with generator. Pythogorian triplets and a triplets of integers (x,y,z) where x*x + y*y == z*z; or x**2 + y**2 == z**2 Please go to Page 1 for definition of out generators integers() and take()
You can use generator one by one with function next(). In this case generator will remenr it's iteration
How to join generator into a stringIt is possible to join generator into a string with function .join(). It is important to remember that this generator must produce object of STR type.
|
Last 10 artitles
9 popular artitles
|
|
© 2020 MyCoding.uk -My blog about coding and further learning. This blog was writen with pure Perl and front-end output was performed with TemplateToolkit. |