Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book


Transcript #4: Python 3 is just fine for beginners thank you, q is awesome for debugging, and more

Return to episode page view on github
Recorded on Monday, Nov 28, 2016.

00:00 This is Python Bytes. Python headlines and news delivered directly to your earbuds.

00:04 Episode 4 recorded November 28th, 2016.

00:08 This episode is brought to you by Rollbar. They help you take the pain out of errors.

00:12 Hey Brian, how's it going?

00:13 It's going really good.

00:14 Yeah, we had a Thanksgiving break, which meant kind of a shake up in a lot of the news and the topics and whatnot.

00:22 But that does not mean it was not interesting or controversial.

00:26 It was a very controversial week last week.

00:28 In fact, it might be one of the most Pythonically controversial Thanksgiving's ever, if I had to guess, I don't know, trying to intersect those two things.

00:36 Yeah, so let's jump right into that as the first item that we're going to cover.

00:41 And we'll sort of lay this out for you.

00:42 So you may have heard that a guy named Zed Shah has written a very famous book teaching people to write programming, basically teaching people to become Python developers.

00:53 Okay.

00:54 He wrote this article called "The Case Against Python 3" or something to this effect.

01:01 And it turned out this article, which is a huge, long, in-depth, highly charged criticism of Python 3.

01:10 It's like 15 pages long.

01:11 And it basically, let me just read you a short excerpt straight from the article.

01:16 And remember, this is coming from the person who is the author of the primary book for learning Python.

01:23 It's referring to Python 3.

01:25 It's as simple as that.

01:26 If you learn Python 2, you can still work with a legacy Python 2 code in existence until Python dies, or hopefully you move on.

01:34 But if you learn Python 3, your future is very uncertain.

01:37 You could really be learning a dead language and end up having to learn Python 2 anyway.

01:42 Quote Zed Shah.

01:43 Now if this was just some guy on the internet, like who cares, right?

01:47 But the fact that this guy is our greeting person, this guy greets the new developers and welcomes them to Python and says, "Gee, Python is great and you can even use it until it dies or hopefully you move on." This is actually a really big problem.

02:00 How did this whole experience strike you?

02:02 It was hard to have coherent words come out when I was trying to express how angry I was about this article.

02:09 I'm just shocked by it, actually.

02:11 Yeah, I think shock and awe is really quite an appropriate summation of a lot of people's feelings.

02:18 people writing me on Twitter going, what, what is this? Oh my god, this doesn't even like, like, they couldn't even like cognitively put it together with Zed Shah being the author of that book.

02:28 So let me like, like I said, it's a 15 page article. Let me give you a few of the key points. In fact, I was able to condense it down pretty tightly, I believe, and everyone out there listening can decide sort of what this means to them.

02:41 So there's a couple of key points. First of all, Zed says it's learning Python 3 or Python 3's existence is not in your best interest.

02:49 And so this is quote, the Python projects effort to convince you to start with Python 3 are not in your interest, but rather are in the best interest of the Python project.

03:01 That's a case or point one against Python 3.

03:05 Number two is you should be able to run Python 2 in the same process as Python 3.

03:11 Like so they should be able to coexist in the same process as an execution engine.

03:17 And the fact that no one has written a Python 3 interpreter that does this shows that Python 3 is not Turing complete.

03:25 It's one of the reasons that newcomers to the language can't use Python 3.

03:28 I don't really understand that, but that was one of the major arguments, the Turing completeness, because Python 3 has not been made to host Python 2, which I think is actually not even correct, but also not making a lot of sense to me.

03:41 But it also doesn't make sense that a newcomer would want to try to write a Python 2 interpreter in Python 3.

03:46 It doesn't seem like a beginner task to me.

03:49 Yeah, absolutely.

03:50 So I actually had an exchange with Zed on Twitter.

03:54 He was busy.

03:55 He was talking to many people because a lot of people had the feeling that you and I did like, well, we'll get to that at the end.

04:01 But we had this feeling that we just want to reach out.

04:03 And so it really comes down actually to his, even though it took 15 pages in turn completeness and computer science and all sorts of stuff, the actual complaint is the way the strings changed in Python 3 are hard.

04:15 So here's a quote again from the article, the strings in Python 3 are very difficult to use for beginners, and in an attempt to make strings more, quote, international, unquote, they turn themselves into difficult to use types with poor error messages.

04:28 And so that that was straight from the article as well.

04:30 So in my final analysis, I would say this, there's a huge uproar on Twitter, and various other things like on Reddit, I think I got like 500 upvotes across a couple of people who reposted this saying basically, look, I'm going to absolutely scare newcomers to Python away from Python three. And here's why you can't add the byte string hello to the Unicode string. Hello, I'm Python three that will crash. There's too many string formatting choices and bytes aren't decoded to strings automatically, you have to pick the encoding and explicitly do that.

05:04 Therefore all newbies should avoid Python 3 like the plague.

05:06 It'll curse your career and cloud your judgment.

05:09 So that was Thanksgiving in the Python world basically.

05:12 Yeah, that's just weird.

05:14 I really have a hard time imagining that a newcomer to Python would need byte strings or byte arrays right away.

05:22 Just not sure about that.

05:23 But yeah, I mean, surely after a while, like if you were the person writing a network layer, like if you're writing requests, you're writing flash, you're writing pyramid, you got to to deal with this stuff.

05:31 But beginners don't do that the first day.

05:34 They just work with strings and they might get something from a framework that's already done that decoding for you.

05:39 It's crazy.

05:40 - Yeah, and I learned in Python 2 and the conversion to Python 3 was very painless.

05:45 I mean, the only thing, I remember, gosh, the only thing I was waiting for was one of the libraries that I depended on.

05:53 The interactions with DLLs was a little different, so some of the, because of the string things.

05:58 But let's face it, Python 2 used basically C strings, and they aren't normal, just arrays of characters, and that's not good enough, it's not real.

06:08 And it's actually, the argument's a lot contradictory to itself because the many formatting choices for strings are because we've came up with lots of better ways to format strings and kept the old ones for backwards compatibility, which is exactly what Zed wants us to do to keep backwards compatibility.

06:26 And yet there was this, one of the things that caused the break between two and three and make 'em not backward compatible is this decision about strings.

06:35 And I just, at first I disagreed with it, but after working with it for a while, I totally understand the choice and it makes sense.

06:42 - Yeah, I think, I don't know what the alternative is.

06:44 Sporadic runtime errors?

06:46 Great.

06:47 You know, I mean, come on.

06:49 So, and it's one thing to say, strings in Python 3 suck.

06:52 Like, that's a reasonable contention.

06:55 I don't make that myself, but you could.

06:57 But to then make that immediately to be the case that you should absolutely stay away from Python 3 and even Python 2 is kind of a bad choice for you, but you can kind of stick with it for a while.

07:07 Like that is, one does not follow from the other.

07:10 So I got worked up and I was gonna write up something about this, but this guy, girl, I don't even know the gender, Eve, E-E-V-E-E, wrote a fabulous point by point logical rebuttal of this and then sort of a personal comment as well.

07:24 So we're going to link to that, which has the original articles, quotes, as well as comments about it in our show notes.

07:30 Yeah.

07:31 And I'd like to just say for anybody that's actually freaked out about this at all, don't be freaked out.

07:36 It isn't a big deal.

07:37 And for history reasons, or just a little background, Zed does like to jump up and down and make a lot of noise every once in a while.

07:45 Yeah.

07:46 Yeah.

07:47 He even said on Twitter that he was looking to move on from Python.

07:48 So that's fine.

07:49 I mean, I totally respect that.

07:50 I've moved on from other technologies to Python, actually.

07:53 But don't poison the well on your way out the door as your last act.

07:58 So personally, I'm not going to recommend Zed's book anymore.

08:02 Just as a point of, I just don't think this is the person that should be representing the first touch with people coming into Python.

08:09 So everyone else can do whatever they like.

08:11 All right.

08:12 I agree.

08:13 Right on.

08:14 So let's talk about something newer, something in Python 3, actually.

08:17 Okay.

08:18 things that has come up in Python 3 as our second article is the async I/O has changed quite a bit and in Python 3 it's sort of gone through several iterations and I'm not really an expert on it but there was a Reddit discussion talking about an article the article is actually from February but the Reddit discussion is about the async I/O for the working Python developer and And actually the article that we'll link to is I think a pretty okay tutorial on understanding some of the different terms, like, now I'm even gonna blank on 'em, but like futures and threads and tasks.

08:59 And I think it does a pretty good job.

09:02 There's a couple downsides.

09:04 It does use Python 3.4 syntax, and the syntax has changed.

09:09 It still works in 3.5, but there is a newer async await syntax in 3.5.

09:15 - Yeah, and that makes it much more approachable, I think.

09:18 It makes the code change significantly less coming from a synchronous model to an asynchronous model.

09:24 Let the implementation or runtime deal with that for you.

09:27 - Yeah, but in that regard, I'd actually like this sort of, so this is one of the reasons why I included it.

09:34 I'd like somebody to take this type of an article and write it with the new async await keywords, And it would also be great if they could come up with an example that didn't include just like sleep statements.

09:46 - Yeah, a real world example would be great.

09:48 - Yeah, so anyway, that's my second article.

09:53 - Yeah, and if you're looking to get into async stuff in Python, check this one out.

09:57 It's cool, we'll have another thing later in the show as well about async.

10:01 All right, so my second choice here was Piston, P-Y-S-T-O-N, which is an alternate implementation Python as opposed to say CPython. And this actually is maybe most notable because it's coming from Dropbox where Guido van Ralsom and crew work and Dropbox is one of the biggest sort of users of Python in the commercial space and so it's a real really is a center of the Python universe. So they're working on a JIT version, a just-in-time compiled version of Python that is different than CPython. So that's pretty cool. This release is the 0.6 release. The main goal was to reduce the overall memory footprint. So they actually, there's a couple of interesting comparisons.

10:45 It's 50% better than it was before. And let me look at the graph. Yes, in every single case the memory usage is actually better in piston. Now it wasn't before now it is compared to pypy, P Y P Y, which is the other major active JIT implementation for Python. So they They also picked up some of the Python 3.6 features like order dict and so on.

11:08 - Okay, I guess I'm misunderstanding the graph.

11:12 It is, it's still larger memory footprint than CPython.

11:17 - It is still more memory than CPython because I believe it's a reference counting garbage collector, I don't know that for sure, but I think it's a GC-based language possibly, which generally means more memory usage.

11:30 Certainly PyPy is GC, which means more memory usage.

11:34 So it's interesting.

11:36 I don't think it's really there yet.

11:37 I'm not totally sure.

11:39 They focused a lot on NumPy implementation and some of the scientific stuff.

11:43 But it's nice to know there are many implementations of Python and here's yet another.

11:47 - Yeah, it would be cool.

11:48 And I think it'd be kind of neat if we could get somebody from the Piston Project to maybe go on your show.

11:55 - Yeah, I would love to have them on Talk Python.

11:57 I actually talked to them a little bit when the project was announced like a year ago.

12:01 And they were like, "Hmm, maybe." I don't believe anybody ever agreed to come on the show, so I might have to follow up with that.

12:07 You're right, that would be cool.

12:07 I've had the Pigeon guys on, which is the Microsoft's version of that, which is actually really cool.

12:13 Some of the Python core developers are working on it, Brett Cannon and groups.

12:17 I had them on my show, and that was a super interesting topic.

12:20 - Yeah, it is interesting.

12:21 I'd be interested to hear some of the motivation, because if, I mean, Dropbox is throwing money at it.

12:25 There must be a reason by around there.

12:27 It's not just they're curious, so.

12:30 - No, there's something.

12:31 They actually are not using it in production yet, but maybe they're looking to, we'll see.

12:36 - Yeah, okay.

12:37 - Before we get to the next one, I'd kinda like to tell you about our sponsor.

12:39 How cool is it that we have a sponsor already?

12:41 That's great, right?

12:41 - Yeah, I'm very grateful to these guys.

12:43 - Yeah, Rollbar's awesome.

12:44 So I actually use Rollbar.

12:45 I used Rollbar before they sponsored the show.

12:47 So let me just tell you about them.

12:48 So on the Talk Python websites, those across three sites there, they handle almost two million dynamic HTTP requests a month and transfer upwards of five terabytes of data.

12:58 But I deploy to them several times a week, and I'm not even worried about pushing them out because in addition to continuous integration, like if something goes wrong, my Slack, my email, my phone, everything will be blowing up with notifications from Rollbar saying something broke, click, click, click, check the server.

13:13 And you'll get detailed error ports whenever something's wrong.

13:17 If there is an error, usually don't even have to debug it 'cause all the info is right there.

13:20 So you Python Bytes listeners, you can have the same peace of mind.

13:24 Just visit rollbar.com/pythonbytes, which is also in the show notes and sign up for the free tier.

13:28 So thanks Rollbar.

13:29 Thank you, Robert.

13:30 And also, while you're there, there's a really fun demo you can play with.

13:33 All right.

13:34 Let's talk about Docs.

13:35 OK.

13:35 I just heard about this last week.

13:37 I'm not sure when they announced it.

13:39 But there's a website called pydoc.io.

13:43 And we're actually going to link to the announcement.

13:48 It's on the Read the Docs site.

13:51 I forgot who's behind this.

13:52 But the idea is similar to a lot of API documentation generators.

13:58 but it looks like they're gonna try to automatically generate documentation about the APIs for at least a whole bunch of PyPI repositories.

14:09 - Yeah, they said they're starting with the popular ones, but they said eventually they're planning as to auto-generate API references for every package on PyPI, so that's over 90,000 packages.

14:17 That's pretty awesome.

14:19 - That's kind of incredible.

14:20 Yeah, it may surpass all of the rest of the stuff on the Read the Docs right now, but I'm not sure.

14:25 - Yeah, so it's really interesting, and I'm not really sure quite how it works.

14:28 Maybe it looks at the actual documentation in your Python code or whatever, but yeah, have a look.

14:33 If you have a package out there and you wanna make sure it shows up well here, be sure to check that out.

14:37 - Yeah, a few of the packages they've got so far, I looked around, it looks pretty neat.

14:41 - Yeah, absolutely.

14:42 I was cruising through requests, it's up there, of course.

14:45 So we talked about things that maybe advanced people care about, like converting bytes to byte strings and whatnot to regular strings or whatever, But I found an interesting article, really a conversation that I wanted to highlight.

15:00 And the question was, what's the one thing or the primary thing that took your Python experience to the next level?

15:06 And this is asked by a guy who's had like three months of Python and trying to get into it.

15:10 And so I picked out five that I thought were pretty cool.

15:13 So the first one out there said, that sort of changed their relationship with Python and how they wrote code was mastering generators.

15:22 Another person said, how iteration really works.

15:25 Understanding how iteration really works opens up so many possibilities, like learning how to do tuple unpacking, playing with zip, enumerate all, any, looking at iter tools.

15:36 I find it's interesting in Python, another person said, list comprehensions, how important iteration and sort of processing streams of data is, right?

15:45 - Yeah, these are good.

15:46 - Yeah, these are good.

15:47 One of them I think is gonna be near and dear to your heart is unit testing and pytest in particular.

15:51 - Yeah, I would probably say do system level tests first, but yeah, I agree.

15:57 - Well, it changed this guy's life.

15:58 So another person said, "For me, all of David Beasley's work, "in particular, his work on coroutines," which was sort of hinting at the async I/O stuff as well.

16:09 - Maybe I should check that out.

16:10 - Yeah, we could check that out for sure.

16:12 - One of the things I'd like to add to this is the, I see a lot of people that already know several languages, and then when they come to Python, there's a desire to just jump in the deep end and skip over some of the basics. And I think anybody that's in that boat should go back and make sure they understand all the basic data structures in Python because misusing data structures and things like for loops and if-else and all those things and some of the comparison operators that are different than other languages can make your code a lot better right off the bat. Yeah, absolutely. I think it's - It's one of the curses of Python's ability to be quickly and easily learned.

16:52 You don't have to trudge through all the details.

16:54 You can almost just jump in right away.

16:57 But you do actually overlook some of its really beautiful, nuanced aspects of it if you just have the same mindset as say coming from C or whatever.

17:05 - Yeah, I still find people that are surprised that have actually written Python for a long time that don't know that you can do two comparisons in an if statement.

17:14 You can say if one is less than x is less than 12 or something like that.

17:19 - Yeah, I tried PipePipe and it didn't work, so it must not be in there.

17:22 You know, so when you write code like that, you probably want to debug it easily, right?

17:26 And the best place to learn how to quickly and easily debug your code is from my dinosaur.

17:31 - What?

17:32 - The guy who gave the talk was wearing a dinosaur suit.

17:34 - Oh yeah, yeah.

17:34 - So I'm talking about Q.

17:38 Our friend Luciano Romalo gave us.

17:41 - Oh yeah, totally.

17:42 You like set it up for me and laid it up I just dropped the ball. I was playing baseball over in the corner.

17:48 Dinosaurs.

17:49 So, Luciano Romano tweeted out something really cool and we both picked up on it.

17:53 Yeah, Luciano Romano, by the way, way cool name. There's a product, a project on PyPI called Q and it's a quick and dirty debugging output for tired programmers. And there's a link to a five minute lightning talk by, now I'm going to forget this guy's name. It was something cool also.

18:14 Ping.

18:15 - Yeah.

18:16 - And the gist of it is just a way to add logging that saves to a file and in very little code.

18:24 And this is something you can add even to a running like a web service or something that you have no idea where standard out and standard error are going.

18:33 And you could still add some logging to find out what's going on.

18:36 - Yeah, it's really cool.

18:37 What I really like about it is you basically say, the guy hates typing.

18:40 So everything's like one letter, which we could debate the merits of that.

18:43 But you go instead of log something or print something, you say Q.Q and you give it an expression.

18:48 It can be as complicated as you want.

18:49 And it will actually figure out the expression, the method it's in, as well as the value and give you a little summary.

18:56 It's really cool.

18:57 There's also a tracing thing.

18:58 So if one function is being called with the wrong parameters, and you're like, why is this happening?

19:03 You can put like a decorator Q.T on that function and it will trace the entire call stack with the name of the function, all the local parameters that are passed and so on.

19:11 - Yeah, and just watching him in this talk to add fairly complete logging onto a module in like, I don't know, 20 characters that he added to the file, it's pretty cool.

19:23 So definitely check it out.

19:25 - And a bonus 'cause he's in a dinosaur suit.

19:27 - Yeah, he's also in a dinosaur suit.

19:29 One of the things I liked about it is because I'm one of those quick and dirty debuggers that I will not reach for the debugger first, I will reach for logging, and so this is good.

19:38 - Yeah, it was really cool.

19:39 And it's a five minute lightning talk at a PyCon, but it's like 25 minutes in, and so the link I put in there actually has the timestamp in it, so it should jump right to his talk.

19:49 - One of the things I liked is just, it's a decent example for giving a good lightning talk as well.

19:54 - Oh yeah, it was really compelling, people loved it.

19:57 - Yeah. - All right, that's it for the news.

19:59 You might have thought Thanksgiving was gonna be dull, but no, it was not.

20:02 Brian, what else is up with you?

20:04 - Thanksgiving has put me behind schedule on my book, and so I'm gonna have to take a little bit of a pause from some of the podcasts.

20:11 Other than this, I'm gonna keep up with this, of course, and catch up on my book.

20:16 I do have some interesting interviews coming up and I'll definitely keep those flowing as soon as, whenever they come in.

20:21 But that's up for me.

20:22 What do you got going, Michael?

20:23 - Excellent.

20:24 You know, not too much.

20:25 I try to catch up on a bunch of things over the downtime on break.

20:29 But also, I just have a quick follow-up from last week.

20:32 We talked about how cool Python 3.6 is and that the release is coming, that was in beta.

20:37 I think I forgot to mention, the expected release date of Python 3.6, according to the official page there, is December 16th, 2016.

20:47 So that's actually coming up in a couple weeks, right?

20:50 We're gonna be having a shiny new Python 3.6.

20:53 It's gonna be great.

20:54 - Yeah, we'll definitely have to include that in that week's Python Bytes.

20:58 - There's no way to avoid that.

20:59 That's gonna be awesome.

21:00 Looking forward to it.

21:01 It was great to chat with you, and thanks for sharing all the news you found with everyone.

21:04 - Thanks for talking with me, Michael.

21:06 - Yeah, you bet.

Back to show page