python_koans icon indicating copy to clipboard operation
python_koans copied to clipboard

about scope

Open gordinmitya opened this issue 4 years ago • 2 comments

Hey, looks like typo in about_scope.py:73

 def test_incrementing_with_local_counter(self):
        global counter
        start = counter
        self.increment_using_local_counter(start)  # should be `counter` instead of `start`
        self.assertEqual(False, counter == start + 1)

Yes, in both cases the answer is False. But logically in start we should keep initial value and then compare with ~~modified~~ counter.

gordinmitya avatar Jul 29 '19 06:07 gordinmitya

Well... I'm going to make admission. I wrote this a long time ago. I have hardly any recollection of writing this koan at all. But... looking back at it with fresh eyes this compared with the next koantest_incrementing_with_global_counter is super confusing. I can see my intent was to show the difference in scope but this doesn't prove it at all well, because the tests for local vs global counters are almost identical!

So I'll throw down the gauntlet. If someone wants to make a cool contribution to Python Koans, this is a great place to start!

gregmalcolm avatar Mar 05 '21 02:03 gregmalcolm

I would like to work on this issue.

ria-19 avatar Mar 05 '21 04:03 ria-19