General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Dr Gamma D
Indently
comments
Comments by "Dr Gamma D" (@DrDeuteron) on "All 39 Python Keywords Explained" video.
Now this is a separate video on coroutines. yield is not just a 'return' statement. It is also an assignment statement. If in a generator called 'foo', you have: new_value = yield old_value a user, baz, of that generator that has declared: def baz.. bar = foo() can then do: current_result = bar.send(my_value) which gets bars's old_value and stores it locally in baz's current_result while at the same time storing baz's my_value in bar's new_value. bar then waits there until anyone calls next(bar). at which point foo's code restarts execution. confused? good, so am I. But I have used these to write a text "continued line" unwrapper, and a clever spacecraft data packet reader in which the length of the packet is not known until the end of sensor scan--with NO, ZERO, NADA if-then clauses. Cyclic Complexity = 1, but it handles all cases WITHOUT indexing past/present data streams, even though the data reading depends on the values of the data stream at different timestamps (read: indices).
7