python-ecology-lesson icon indicating copy to clipboard operation
python-ecology-lesson copied to clipboard

Introducing len() function

Open pr4deepr opened this issue 6 years ago • 12 comments

Addressing #362 to introduce len() built-in python function

pr4deepr avatar Apr 26 '19 09:04 pr4deepr

Could you please restore the 6th episode? It will be deleted from the repo if we merge your PR as is. You can restore the episode with the following commands:

git checkout gh-pages _episodes/06-loops-and-functions.md
git add -u
git commit -m "Restore 06-loops-and-functions.md"
git push your-fork

maxim-belkin avatar Apr 26 '19 16:04 maxim-belkin

Apologies, its my first time doing this. Where do I enter these commands? I use the github website for this..

pr4deepr avatar Apr 27 '19 03:04 pr4deepr

Oh, I see... You can't do what I asked for using web interface. But don't worry -- I'll do that.

maxim-belkin avatar Apr 27 '19 18:04 maxim-belkin

Thank you. Sorry for the trouble . I was trying to undo the changed and didn't realise that would happen.

On Sun, Apr 28, 2019, 4:59 AM Maxim Belkin [email protected] wrote:

Oh, I see... You can't do what I asked about using web interface. But don't worry -- I'll do that.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/datacarpentry/python-ecology-lesson/pull/376#issuecomment-487311137, or mute the thread https://github.com/notifications/unsubscribe-auth/ADJQ2IQFRO4VFFMS7KY2VELPSSPARANCNFSM4HIUFRAA .

pr4deepr avatar Apr 27 '19 22:04 pr4deepr

No worries. It was not difficult to fix -- I just was not sure if you wanted to do it yourself or not. I'll let April (@wrightaprilm) chime in on the content.

My thoughts: the question, if added, should be reformulated as:

"Find the number of elements ("items") in a_list or a_tuple using Python's built-in function len()"

maxim-belkin avatar Apr 28 '19 04:04 maxim-belkin

Thank you. Ideally, I would have liked to do it, but I am still figuring how to contribute using GitHub website and do not want to mess things up.

I do like the reformatted challenge question.

On Sun, Apr 28, 2019 at 2:08 PM Maxim Belkin [email protected] wrote:

No worries. It was not difficult to fix -- I just was not sure if you wanted to do it yourself or not. I'll let April (@wrightaprilm https://github.com/wrightaprilm) chime in on the content.

My thoughts: the question, if added, should be reformulated as:

"Find the number of elements ("items") in a_list or a_tuple using Python's built-in function len()"

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/datacarpentry/python-ecology-lesson/pull/376#issuecomment-487341488, or mute the thread https://github.com/notifications/unsubscribe-auth/ADJQ2IXAJW5PDNGG3CZVYXTPSUPK5ANCNFSM4HIUFRAA .

pr4deepr avatar Apr 28 '19 04:04 pr4deepr

No problem, Pradeep. Could you please clarify how your contribution adds to the discussion of lists versus tuples?

maxim-belkin avatar May 06 '19 21:05 maxim-belkin

The idea was to show that the same built-in function can be used for looking at two different data structures, and to introduce the len() function. It may make sense if either the tuple or list had different number of items. That way, getting the length of a tuple and list will return different values. Is this complicating things in the intro lesson?

pr4deepr avatar May 06 '19 23:05 pr4deepr

I'm on the fence with regards to this PR. Let me first argue why I think it should not be merged and then on what grounds it can be merged.

NAY: I think that when we're talking about differences (between any two things) it is important to highlight exactly them, not the common things. This way these differences have a better chance of sticking in our minds. len() function can be used for any data type that has __len__ method implemented, so it is not unique to lists-vs-tuples.

AYE: We could, actually, start with the len function instead of finishing with it. The logic would be that we first mention a "common ground" and then discuss differences.

I'll let @wrightaprilm make the final decision.

maxim-belkin avatar May 17 '19 14:05 maxim-belkin

I'm also a little bit on the fence - we do introduce built-in functions in this lesson, so I like the idea of having the learners just try another built-in.

And my hesitance isn't about this pull request, per se. One thing that this lesson is kind of weak on is tuples as a data type. The why isn't well explained, and I often skip them for later when I use these materials. What if we edited the question to be about the built-in function? As in "What information does the built-in function len() provide? Does it work provide the same information on both tuples and lists? Does the help() function confirm this?" That way, we're emphasizing that these are both iterable types, just that one is immutable.

wrightaprilm avatar May 17 '19 15:05 wrightaprilm

What if we edited the question to be about the built-in function? As in "What information does the built-in function len() provide? Does it work provide the same information on both tuples and lists? Does the help() function confirm this?" That way, we're emphasizing that these are both iterable types, just that one is immutable.

I like that idea.

maxim-belkin avatar May 17 '19 16:05 maxim-belkin

Hi, Pradeep! Did you want to update the PR as we discussed above? Do you need any help with that?

What information does the built-in function `len()` provide?
Does it provide the same information on both tuples and lists?
Does the `help()` function confirm this?

maxim-belkin avatar Jan 28 '20 18:01 maxim-belkin

I'm helping the current lesson Maintainers process outstanding pull requests on this repository, in preparation for transition to the new lesson infrastructure.

@pr4deepr thank you for contributing this suggested change. Reading through the conversation above it seems the former lesson Maintainers settled on a suggestion for how the exercise text could be adjusted to address the issue. If you are still interested in contributing this change, please resolve the conflicts that have been introduced in the intervening years then update the pull request (or close it and open a new one) based on the suggestion above before the end of April. After that, the infrastructure transition will invalidate your fork and we will have to close the PR. Let me know if there's anything I can do to help.

tobyhodges avatar Feb 28 '23 11:02 tobyhodges

Closing in favour of #449

tobyhodges avatar Apr 04 '23 09:04 tobyhodges