-
Notifications
You must be signed in to change notification settings - Fork 163
-
Notifications
You must be signed in to change notification settings - Fork 163
[Python] Implement new Concept Exercise: list methods #2170
Comments
🔥 🔥 🔥 -- @DavidGerva you are on a roll! Many thanks for this. |
@mohanrajanr will be taking this on. YAY. |
@DavidGerva @BethanyG : To Test this exercise, I came up with the following plan. class ListWrapper(list):
def __init__(self, iterable=(), **attr):
super().__init__(iterable=iterable, **attr)
self.execution_history = []
def append(self, value):
self.execution_history.append('append')
super().append(value)
def extend(self, value):
self.execution_history.append('extend')
super().extend(value)
a = ListWrapper()
a.append(1)
a
#=> [1]
a.execution_history
#=> ['append'] This looks like a more plausible way to understand whether the user used the function in the code. All the Test cases will be manipulating the list which we pass ( the list wrappered object is the one we will pass in the test ) and we can test all the list methods :) . At first i thought whether we can monkey patch built in object or use decorator of some sorts, but listwrapper seemed more easier to do. Thoughts?. And Also, I know Jeremy has an Issue raised about differentiating on exercises and concepts. So Should I go on with the PR or should I wait? |
As a rule on exercism, test don't test implementation. This has three reasons, if not more:
However, we have a way to guide a student to use specific implementations! We allow analyzers to test implementation. This has a sidenote: we often suggest you only give feedback on proven positives, and not potential positives. What does this mean? Instead of analyzing "uses append", you would instead analyzer "uses for each" and suggest |
Just continue. You're doing great, and it's easy for us to "fix" / do another PR to update once that idea lands. No need to wait. |
@SleeplessByte : Thanks for your comments.
Got it!. I think this line resonates better about the thought i should give on writing test cases.
Great. I will proceed working with this. |
Created a PR for this Issue here : #2303 |
I missed this issue when it was created. Was there a discussion at some point on naming this concept "list methods" instead of just "list"? |
Yeah. That naming struggle (and grouping of concept and terms) is ongoing. We already have I am debating if we do an If we were to do that, then there is this space "in between" the basic data structures (what they are, if they are mutable, immutable, how to make one, how to update one) and the more general types and how those get used/interpreted (sequence, mapping, stream, etc.) where there are useful or important methods specific to only that class ( I'll admit that
Thoughts? These are things that are important for a student as basic building blocks, and I don't think the |
Not to mention that we also have a I do like the idea of an |
Since PR #2303 has been merged 🎉 , I am closing this issue. |
This issue describes how to implement the list methods concept exercise for the Python track, which should familiarize the student with the core
list
methods.Getting started
Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
Please also watch the following video:
Goal
This concept exercise should familiarize the student with some of the core list methods that manipulate/mutate
lists
, and when/how to use them.Learning objectives
list
class & its core methodslist
to operate on itlist
methods mutate the list -- they do not return or make a newlist
.list
methods -- one at least from each grouping below to mutate a list:append()
/extend()
methodsinsert()
methodpop()
/remove()
methodssort()
/reverse()
methodsreturn a shallow copy of alist
with thecopy()
methodlist
with thecount()
methodindex
of the element in alist
with theindex()
methodunderstand how the elements of two lists are comparedOut of scope
min()
,max()
, andlen()
deque
&UserList
list
comprehensionsmap()
andreduce()
for operations on alist
list
as an argumentlist
with thecopy()
method vsdeep_copy()
Concepts
list
Prerequisites
basics
booleans
iteration
,iterables
loops
methods
sequences
Resources to refer to
Hints
After
Explain more about:
methods
oflist
& Pythonsbuilt-in methods
called with a list as argument (e.g.reversed()
,sorted()
,len()
...).lists
Representer
No changes required.
Analyzer
No changes required.
Implementing
Tests should be written using unittest.TestCase and the test file named comparisons_test.py.
Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue.
Edits
The text was updated successfully, but these errors were encountered: