Jump to content

This week we learn about sorting and importing information with a YouTube API! http: youtu be M...


G+_Shannon Morse
 Share

Recommended Posts

I like the show, but this episode leaves me feeling a little disappointed.  Here are some reasons:  In Padre's segment, he ends up only teaching one new method you can use on lists.  How about showing some of the other methods you can use on lists like count, index, remove, insert, and reverse?  I think new programmers would appreciate that information more.  For a stretch, he could have shown slicers and negative indexes which make python lists so unique.

If Padre really wanted to concentrate just on sorting, I think he missed the opportunity to demonstrate different sorting algorithms.  The algorithm Padre showed is just one way to sort.  Does Padre not want to say the word "algorithm"?  His algorithm uses two lists.  The one inside of python sorts in-place.  Why not show an in-place sort?  I think that he missed the opportunity to introduce new programmers to some classic algorithms that they could experiment with and learn more about on their own.

Then we have Dale's segment.  Do Padre and Dale talk beforehand about what they want to demonstrate?  Dale's segment almost didn't build on Padre's segment at all.   I wished that these new acronyms like API and JSON were defined better as Dale introduced them.  API = Application Programming Interface.  JSON = JavaScript Object Notation.  For those of us that actually want to try the YouTube API, there was no information in the show notes, but I guess we can use Google to find what we need.

So, those are all my reasons for being kind of disappointed this week with the show.

Link to comment
Share on other sites

I don't think it's a bad idea to put off discussion of algorithms for a while, but I think more serious is not having better discussion of data types and structures. One can be a productive programmer completely relying on the standard algorithms built into most modern languages, but you really need a more solid understanding of data to do anything. For example, can you spot the bug in Shannon's program that will make it fail for certain guests? It's a consequence of her using simple strings for everything and not organizing her data well. Programmers have a slang term for such a program--we call it "stringly typed"--a pun on "strongly typed" and a common affliction of novice coders. Of course, covering this topic well will require fixing the show's more fundamental problem, which is that it has three entertainers and no experts.

Link to comment
Share on other sites

I thought Padre's explanation of sorting was fine for beginners. Dale's program was cool but a little too much for his allotted time. In a beginner's class, each line of code needs to be carefully explained or you lose people. Plus the example should be something everyone can run. The need of a YouTube Key was really lame. Fortunately we have people in here like Lionel D to fill the void with his great apiSort.py program.

Link to comment
Share on other sites

I tried recreating the program and data file and I indeed tripped it up by adding a name of Yesenia Diaz. Probably the best thing to do is do all the reading and splitting before the if statements. Put them in a list matrix that looks like:

 

[['Shannon Morse', 'Yes'], ['Keith Coffman', 'Yes'], ['Aunt Morse', 'No']...

Link to comment
Share on other sites

Just doing .find("-Yes") would be better but since some names contain hyphens you really need to use a separator that isn't found in names like "|" or "*". Then doing .find("|Yes") would be 100% reliable. The "Pro" way would be to split Guest into a 2-element list that separates the name and reply:

for Guest in Names:

    nameAndReplyList = Guest.split("|")

    if nameAndReplyList[1].strip() == "Yes":

        print nameAndReplyList[0],'has replied YES'

    elif nameAndReplyList[1].strip() == "Not replied":

        print nameAndReplyList[0],'has NOT REPLIED'

    else:

        print nameAndReplyList[0],'has replied No'

Link to comment
Share on other sites

Lee Crocker Ahh, Dale actually said that to me when we were working on my code. "Luckily none if the names start with No or Yes, otherwise this method wouldn't really work.

 

That's also why i left the space in " Yes". To cut down on the chance of a false positive.

 

To make it really bulletproof. We could do  Keith Coffman-Yes. And do a second split on the -."

Link to comment
Share on other sites

Or using my new favorite list comprehension and a dictionary object:

 

WeddingRSVP = text_file.read()

namesList = [(nameReply[0], nameReply[1].lower()) for nameReply in (rsvp.split("-") for rsvp in WeddingRSVP.split(","))]

replyDict = {'yes':'replied YES', 'no':'replied no', 'not replied':'NOT REPLIED'}

for guestName, guestReply in namesList:

  print guestName, "has", replyDict[guestReply] + "."

 

EDIT: fixed it so that the split only happens up once for each name-reply.

Link to comment
Share on other sites

My point is that using a single string object to represent multiple pieces of data and using a string search to pick it apart shows a lack of understanding about data representation. Strings are great for things that are actual text: names, program prompts, and such. But everything else should be numbers, and collections of numbers and strings (i.e., structures or objects).  

 

Here's a simple version of Shannon's program showing a very basic use of a "Guest" object:

http://github.com/lcrocker/Coding-101/blob/master/wlist.py 

 

I'm still using the"Yes/No" text for responses for compatibility with Shannon's existing data, but I'd really prefer a number for that, indexing into a fixed set of responses. Computers use numbers. You need to learn to use numbers to represent things. Underneath, strings are just collections of numbers too, but they hide a lot of complexity underneath that most programs don't need, and you shouldn't rely on them as a crutch.

Link to comment
Share on other sites

Folks... we know that this isn't the end-all of programming shows. That's why it's called "Coding 101" -- Our job is to introduce basic concepts and give the audience a foundation from which they can learn more advanced topics.

 

We have 30-45 minutes each week and only 8 weeks per language module. That means we have to pare down what we cover to a bare minimum. Will we miss a lot of material? Of course. Do we wish we could cover more? Absolutely. Will we disappoint more advanced programmers? You betcha. But we're aiming our show at those who are thinking about taking up programming... and for that... I think we've got a good mix.

 

Still... if you have a better way to teach the material (and remember... 30-45 minutes x 8 per language -- AND the lesson much be accessible to the absolute beginner), please let us know. We'll incorporate your suggestions into the show.

 

Peace,

Padre

Link to comment
Share on other sites

I'm sure experienced programmers aren't listening to learn basics--I hope to occasionally learn about a language or tool I don't use (like C#), or to see interesting people or projects (like Randall & the ISS tracker). That's been great. When you are doing educational episodes, I don't think you have any choice but to go at a much-faster-than-normal-lessons pace, let listeners do some research on their own, and answer their questions here or on the show. The show then would be left with (a) cover some single topic well, (b) post a good, complete, well-written piece of code that demonstrates that topic--and which will necessarily contain many other things we haven't explained yet, but that's OK, and © answer questions from last week about those things. I think that would be a great show, if the quality were ensured by having a real expert like Lou explain to you & Shannon, then for you two to interpret for the beginners. I think you can have a great show here, you just need to start with quality educational content that can only be provided by a real expert.?

Link to comment
Share on other sites

 Share

×
×
  • Create New...