[Tutor] How to separate UI code from program logic?
robertvstepp at gmail.com
Sun May 6 18:29:09 EDT 2018
On Sun, May 6, 2018 at 5:05 PM, Alan Gauld <alan.gauld at yahoo.co.uk> wrote:
> On 6 May 2018, at 23:00, boB Stepp <robertvstepp at gmail.com> wrote:
>>My understanding of best practice here is that I should not have any
>>print() calls inside my generate_collatz_sequence() function. I
>>_could_ store the generated sequence in a list and return it, but that
>>does not seem like good use of RAM if some user-supplied seed value
>>led to kazillions of Collatz sequence numbers being generated.
> The clue is in that last word.
> Write a generator function that yields the intermediate results.
Aha! Of course the book I am poking around in does not even cover
generator functions ... But I will plow ahead as usual and implement
your suggestion. Thanks, Alan!
More information about the Tutor