Most voted "generators" questions
A generator is a generalization of a subroutine, used primarily to simplify the writing of iterators. The income statement in a generator does not specify a coroutine to jump to, but passes a value back to a parent routine.
Learn more…15 questions
Sort by count of
-
9
votes1
answer1798
viewsWhat are the advantages of using a "Generator" (Yield) in PHP?
As of PHP 5.5, the Generator. It can be used within a function from the keyword yield. In the manual, we have an example where one is compared to function range(0, 1000000) (that theoretically would…
-
8
votes1
answer439
viewsWith doing an iterator/Generator in javascript?
In PHP, we have the Iterators and the Generator. Iterator example: $f = new FileSystemIterator(__DIR__); foreach($f as $file) { echo $file->getFilename(); } Example Generator: function…
-
7
votes1
answer253
viewsDifference between Yield and Yield* operators in Ecmascript 6.0 "Harmony"?
I’m studying the use of generators in Ecmascript 6.0 "Harmony". I have already managed to understand its basic functioning, like the statement through the syntax function* () { ... } and value…
-
3
votes2
answers60
viewsHow to "simulate" a Generator in versions prior to PHP 5.5?
From PHP 5.5 we can use yield instead of return functions and, with this, we create Generators. The reasons for using the yield can be seen here What are the advantages of using a Generator (Yield)…
-
3
votes1
answer46
viewsUse of generators with while results in infinite loop
I made a small example of using generators to better understand how it works in php. the method getValues is an example of values that would come from a database or any other data source that…
-
2
votes2
answers113
viewsGenerator Expressions
Good, I’ve been trying to optimize my code and I found Enerator Expressions, only I don’t understand any of it. For example: for mCp in mWithoutNone: for ctt in moradasCTT: if mCp[3] == ctt[3]:…
-
2
votes2
answers362
viewsmodel and controller in codeigniter for making Insert in Firebird using Generator
I am new to codeigniter and need to define my controller and model, so when calling the model inserir(), the controller takes the last Generator ID of each table you want to do Insert. I’ll give you…
-
2
votes1
answer912
viewsFormatting a python stored text
I made a random number generator that generates and saves in.txt file I made generate 3 combinations, it happens that when I open the txt the combinations are on the side of the other, as I do to be…
-
2
votes4
answers931
viewsPython columns excel csv
I made this number generator that gets saved in a csv file that I open in excel, the combinations are generated in column A but n want it to appear in A. as I do for her to appear in column B and C?…
-
1
votes1
answer174
viewsGenerating functions: What are the advantages of using them?
Generating function: def geraQuadrados(n): for i in range(n): yield i**2 for i in geraQuadrados(5): print(i) no generating function: def novosQuadrados(n): l = [] for i in range(n): l.append(i**2)…
-
1
votes1
answer29
viewsStop Generator
What would be the best way to stop a Generator? Example: >>> def get_fruits(): fruits = ['Mamão', 'Abacate', 'Melão', 'Banana', 'Maçã', 'Uva'] for fruit in fruits: yield fruit >>>…
-
1
votes1
answer62
viewsThis is the iteration of a nested loop
How to use generators/iterators to achieve the generic iteration of a nested loop? I have the following function implemented in an extremely inefficient way. from pprint import pprint def center(i,…
-
0
votes1
answer355
viewsHow to generate sequential numbers automatically with current year in Rails?
I need that when a new product is created it generates a number ex: 0001/2015 numero/ano_in effect and when it changes year back to zero. I made a helper just to format the number in the views, but…
-
0
votes0
answers48
viewsGenerate web pages using Flask or Django from the tables
I have a schema in a Mysql database. I want to generate the web pages from the tables of this schema. Is there any generator of this in python? A few years ago I was generating a "system" like this…
-
0
votes1
answer92
viewsHow to replace by following a pre-determined python pattern
within txt have 12480 = B X 43200 = B X 47040 = B X 50880 = B X 54720 = B X 58560 = B X 62400 = B X 66240 = B X 70080 = B X 73920 = B X 77760 = B X 85440 = B X 89280 = B X 93130 = B X 96960 = B X I…