reset password
Author Message
freddyg
Posts: 5
Posted 12:24 Jan 25, 2019 |

Hello class, I was wondering if someone could clarify exactly what we are commenting for the assignment. Are we commenting every section of code on the page we are redirected to when we click the "The Ultimate Guide to Python Type Checking" hyperlink, or just specific sections on that  page? If it is only specific sections, which sections are we focusing on? Thanks for taking time to read and reply! 

kmarlis
Posts: 35
Posted 12:33 Jan 25, 2019 |

Hi Freddy, I'm working on it right now and this is what I've been doing. Our group of three people tried to split it up into thirds. I copied all of the segments of code in my section into a python document and gave a little comment above each code segment that gave the header of the section of the website that that code portion came from (if that makes sense). I then gave a brief overview of what that portion was trying to teach before adding the specific comments to the code. 

rabbott
Posts: 1649
Posted 14:56 Jan 25, 2019 |

As you have probably discovered, Python is a BIG language. One can get lost tracing down all the tangential paths. 

I don't expect you to memorize all of Python's features. But I do expect you to recognize features that are (probably) important and to see what you can do to find out where they are explained. For example, Hjelle, the author of the tutorial I've asked you to discuss, knows what he's talking about, and he writes intelligent Python. (I've tried to select readings whose authors are worth spending time with.) Even before he begins his discussion of typing, Hjelle gives an example of duck typing using the len function. Duck typing is one of Python's basic concepts. Hjelle's explanation is quite brief. (In addition, it raises a question that is independent of duck typing.) So, what do you do?

I suggest that you find an explanation of duck typing that makes sense to you so that you understand the basic idea. (The Python Readings list suggests Alex Thornton's discussion.) You might include some notes in your discussion of Hjelle's class TheHobbit  example to remind yourself of what duck typing is.

As I said, Hjelle's example raises an additional issue. What is the __len__ method? It turns out that len is a built-in function, and built-in functions typically have what are called dunder methods. (The term dunder is derived from double-underscore.) It happens that __len__ is the dunder method corresponding to the len function.) So now you have to ask yourself how much time you should spend on built-in functions and dunder methods. The Python readings has a pointer to the built-in functions. You might just check those out. (You will then know that such a list exists and that you can find it when you need it.) The Python readings also has a pointer to an explanation, by Dan Bader, of the dunder methods. You might check that out too. You shouldn't expect to remember everything you see on these side trips, but after taking them, you will be more familiar with the territory. You should also put links to these pages in your annotations.

Hjelle's headline example uses what looks like a strange notation for strings: f"{text.title()}\n{'-' * len(text)}". What is that all about? These so-called f-strings are very useful. I believe they are the best way to format strings. The Python readings does not have a pointer to f-strings. But a google search for  python f string  will turn up a number of good discussions. Check them out. You will want to know about f-strings. 

You will notice that Hjelle uses the term truthy in the headline example. I mentioned that on Wednesday, but you may have forgotten. (It is about non-booleans being interpreted as booleans.) In your comments on the  headline example, mention how truthy works. Discuss why align=left works (accidentally) whereas align=centered doesn't.

In summary, in going through the readings, trace down things that look useful and write brief comments on them. You may find quite a few things. But you are a team of multiple people. So split up the work.

The point of all this is to help you develop a feeling for and familiarity with Python so that when you need that information it will not be completely foreign. This is pretty much the way to learn anything. You should practice using this approach to learning a new area. Expect to find more things than you can possibly remember all at once. But note them down so that you can return to them later and so that the terms will at least be familiar.

After doing all this, you may have lots of interesting things to share with the class!

P.S. You will soon find out that I am not a Python expert. Everything I know about Python, I learned in just this way. There are many things I have not encountered (and therefore don't know), many other things I have encountered and have not bothered to explore (e.g., the @property annotation in Bader's tutorial), and still other things I have explored and have since forgotten (e.g., the @class annotation, also in Bader's tutorial). That's often the way it is. It's more important that you develop the sense that you can find out something when you need to know it than to have everything memorized. This is especially true in our field, Computer Science, where there are always new things to learn, more new things than you can possibly remember all at once.

Last edited by rabbott at 21:21 Jan 25, 2019.