G+_Lee Crocker Posted April 11, 2014 Share Posted April 11, 2014 Episode 12 errata: 1. Padre added a semicolon at the end of his first list, and implied that it was necessary. It's not. 2. Dale got the syntax for a new empty list wrong. It's: newlist = [] 3. Dale's big error: changing a list while iterating over it is a big no-no in every language unless you know exactly what you're doing. He chose the wrong kind of loop for what he wanted to do. If you want to use a loop like: for value in mylist: . . . Changing the list out from under yourself will do weird things, as Dale saw. You're asking the program to give you each element in turn, but then changing the list while it's trying to do that. If you want to delete from a list inside a loop, you'll have to use a loop not based on counting through the items. One way is just pop until you drop: while mylist: v = mylist.pop() This will just pop until it's empty. Another way might be to get the length of the list up front, and loop that many times by number: for index in range(len(mylist)): v = mylist.pop() Link to comment Share on other sites More sharing options...
G+_Larry Weiss Posted April 11, 2014 Share Posted April 11, 2014 Improvising as the live show is recording is always tricky. But the bright side is that we got an example of a "gotcha" that most of us have to figure out for ourselves. Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted April 11, 2014 Author Share Posted April 11, 2014 A successful formula for many great podcasts is an expert and one or more enthusiasts who can ask the expert questions and better relate to the audience. Think SGU: Dr. Novella with the rogues, Star Talk: Dr. Tyson plus a comedian. Security Now: Steve and Leo. SN wouldn't work without both. You need the expert understanding and you need humor and audience sensitivity. This episode had no expert. Snubs & Padre are entertaining, and Padre knows a little of the subject. I don't know what Dale's expertise is, but it's clearly not Python. The C# episodes had Lou, who was pretty good. If he's not a Python guy, then you need to find one. I don't expect Guido, but at least someone at Lou's level or better. Link to comment Share on other sites More sharing options...
G+_L I Posted April 14, 2014 Share Posted April 14, 2014 Whenever I pop items from out of a list/array I always get the length and count backwards that way whatever you delete will be behind you. Link to comment Share on other sites More sharing options...
Recommended Posts