-
Notifications
You must be signed in to change notification settings - Fork 4
Learning Python
Many of us are newcomers to Python. This wiki is for us to learn. To try to come up with solutions, and see if they work. Let's not "give the answer" from those who are expert. Let's see how we learn from books, questions, online tutorials, etc.
#How we learn
We learn in different ways. When I was running a course in bioinformatics in Birkbeck (London) 20 years ago I came up with the following analysis of how people learn programming:
The lecturer tells the class the material and the students write it down.
"Learn X in Y days", "Z for dummies" ... These are usually self-paced.
Go out on the web and find examples of code that other people have written. This can be good if the code is good and terrible if it isn't. See is the code works. Modify it to do something different.
"I want to build something that works!" "I like experimenting". Or a project that's handed out in a class.
Work together to create communal code. The advantages are that people can be helped by other people who understand the learning difficulties and tricks. Disadvantage is that some people don't engage and so don't learn.
Yes, there are people who learn by reading formal documents
We are going to learn Python by working in small groups on relevant projects. In all of these we are going to be requirements-driven, and unit-test-driven We currently have three projects- people have been tentatively assigned
We are going to need a UnitTest Harness, using Python unittest. This is something that the experienced Pythonistas can start on. The Python docs are good and stable. We need a recipe for our tests that everyone can use (only the experts have to know how to set up a test).
This is a learnt skill. A good test suite will think of all the desired outcomes AND all the undesired outcomes. We have to think of all the things that can go right, but also the things that can go wrong. For example, if we have a plantDict.removeMarchantia)` we need to:
- test that
plantDicthas one less entry and no longer containsMarchantia - test that all the other entries are still there
- test that the result is still a valid dictionary
... and several more
But we also need to test for probable error (exceptions):
- what if the dictionary doesn't contain
Marchantiaat the start? Do we continue silently? Or return a value - what if the
Marchantiaargument isNone? (It happens!) - what if
plantDictisn't valid?
... and several more