Working on Comprehension exercises today.
Reflections and Experience
- I really need feedback, when it comes to programming. I cannot face a blank page. I always seem to start with printing something out to screen and then my brain kind of kicks into gear. Everything after that is just type, print, is this what I expected, if not then fix, type, print …
- Exercise 3.1 and I think, I am finally getting good handle on comprehensions.
- from something that would take me at least 10 lines of code to just expressing it concisely in 1!
- I can read Python messages and take a gander at what I need to do next.
- I see a
'_io.TextIOWrapper' object
and know I can iterate over it. - I see
AttributeError: '_io.TextIOWrapper' object has no attribute 'strip'
and realise that it cannot be stripped into parts. I need another way to skin that cat.
- I see a
- And then I took it too far (just like this sentence), and nested a comprehension in another one, in where, I had to learn how to put in a conditional in the form of a ternary operator, in Exercise 3.2 (the commented for loop is much simpler!), but that was very good practice. Really stretched me!
- I caught myself getting distracted a lot. I needed to set a 30 min timer and I spent about 15, looking for where the timer app in my Mint Desktop was, instead of just setting the darned timer on the phone.
- Took an hour to figure out the comprehension for 3.2 and about 20 minutes to do it for Exercise 3.3. Practice helps!
- Watching the solutions, and I realise, I got them right in principle, but that I need to be more aware of what happens to an object in memory, so that I can simplify code. I was able to remove one level of comprehension, which I used just to get the end of a string.