5 kyu

Check the status of the generator expression

Description:

My third kata, write a function check_generator that examines the status of a Python generator expression gen and returns 'Created', 'Started' or 'Finished'. For example:

gen = (i for i in range(1)) >>> returns 'Created' (the generator has been initiated)

gen = (i for i in range(1)); next(gen, None) >>> returns 'Started' (the generator has yielded a value)

gen = (i for i in range(1)); next(gen, None); next(gen, None) >>> returns 'Finished' (the generator has been exhuasted)

For an introduction to Python generators, read: https://wiki.python.org/moin/Generators.

Please do vote and rank the kata, and provide any feedback.

Hint: you can solve this if you know the right module to use.

Fundamentals

Stats:

CreatedDec 24, 2016
PublishedDec 24, 2016
Warriors Trained481
Total Skips64
Total Code Submissions370
Total Times Completed136
Python Completions136
Total Stars14
% of votes with a positive feedback rating90% of 45
Total "Very Satisfied" Votes37
Total "Somewhat Satisfied" Votes7
Total "Not Satisfied" Votes1
Total Rank Assessments8
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Chris_Rands Avatar
  • Voile Avatar
  • saudiGuy Avatar
Ad