« Return to show page
Transcript for Episode #4:
Python 3 is just fine for beginners thank you, q is awesome for debugging, and more
Python Bytes Transcript
Episode #4: Python 3 is Just Fine for Beginners Thank You, Q is Awesome for Debugging and More
Michael KENNEDY: This is Python Bytes. Python headlines and news delivered directly to your earbuds. Episode #4 recorded November 28, 2016.
This episode is brought to you by Rollbar. They help you take the pain out of errors.
Hey Brian, how’s it going?
Brian OKKEN: Its going really good.
KENNEDY: Yeah, we had a Thanksgiving break, which meant kind of a shape up in a lot of the news and the topics and whatnot. But that does not mean it was not interesting or controversial.
OKKEN: It was a very controversial week last week.
KENNEDY: In fact, it might be one of the most Pythonically controversial Thanksgivings ever, if I had to guess. I don’t know. (Laughing) I’m trying intersect those two things. Let’s jump right into that as the first item that we’re going to cover and we’ll lay this out for you.
You may have heard that a guy named Zed Shaw written a very famous book teaching people teaching people to become Python developers. He wrote this article called “The Case Against Python 3” or something to this affect. It turned out this article, which is a huge, long in-depth, highly charged criticism of Python 3. It’s like 15 pages long. Let me just read you a short excerpt straight from the article, and remember this is coming from the person who is the author of the primary book for learning Python. It’s referring to Python 3:
“It’s as simple as that. If you learn Python 2, you can still work with the legacy Python 2 code in existence until Python dies or hopefully, you move on. But if you learn Python 3, your future is very uncertain. You could really be learning a dead language and end up having to learn Python 2 anyway.” -Zed Shaw
KENNEDY: If this was just some guy on the internet, like who cares, right? But the fact that this guy is our greeting person… this guy greets the new developers and welcomes them to Python and says, ‘Python is great and you can even use it until it dies or hopefully you move on.’ This is actually a really big problem.
How did this whole experience strike you?
OKKEN: It was hard to have coherent words come out when I was trying to express how angry I was about this article. I’m just shocked by it, actually.
KENNEDY: Yeah, I think shock and awe is quite an appropriate summation of a lot of people’s feelings. I got people writing me on Twitter going, ‘What is this?’ They couldn’t even cognitively put it together, with Zed Shaw being the author of that book.
So, let me give you a few of the key points – like I said, it was a 15-page article. Let me give you a few of the key points. I was able to condense it down pretty tightly, I believe. Everyone out there listening and decide what this means to them.
There’s a couple of key points. First of all, Zed says Python 3’s existence is not in your best interest.
“The Python Project’s 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.” -Zed Shaw
That’s point 1 against Python 3. Number 2 is:
“You should be able to run Python 2 in the same process as Python 3.” -Zed Shaw
So, they should be able to co-exist in the same process as an execution engine. And the fact that no one has written a Python 3 interpreter that does this shows that Python 3 is not Turing Complete. It’s one of the reasons that newcomers to the language can’t use Python 3.
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.
OKKEN: It also doesn’t make sense that a newcomer would want to try to write a Python 2 interpreter in Python 3; it doesn’t seem like a beginner task to me.
KENNEDY: Yeah, absolutely. So, I actually had an exchange with Zed on Twitter. He was busy. He was talking to many people because a lot of people had the feeling that you and I did. We had this feeling that we just want to reach out.
It really comes down to – even though it took 15 pages and Turing Completeness and computer science and all sorts of stuff – the actual complaint is, the way the strings changed in Python 3 are hard. 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 ‘international’ they turn themselves into difficult to use types with poor error messages.” -Zed Shaw
That was straight from the article as well.
In my final analysis, I will say this. There’s a huge uproar on Twitter and various other things. On Reddit I think it got like 500 uploads across a couple of people who reposted this saying basically, Look. I’m going to absolutely scare newcomers to Python away from Python 3 and here’s why: You can’t add the byte string, hello, to the unicode string, hello, in Python 3, that will crash. There’s too many string formatting choices and bytes aren’t decoded as strings automatically. You have to pick the encoding and explicitly do that. Therefor all newbies should avoid Python 3 like the plague. It will curse your career and cloud your judgement.
So, that was Thanksgiving in the Python world, basically.
OKKEN: Yeah, that’s just weird. I really have a hard time imagining that a newcomer to Python would need byte strings, or byte arrays right away. Just not sure about that.
KENNEDY: Surely, after a while if you’re the person that is writing a network layer, like if you’re writing a request, you’re writing Flask, you’re writing Pyramid, you’ve got to deal with this stuff. But beginners don’t do that the first day. They just work with strings and they might get something from a framework that’s already done that coding for you. It’s crazy.
OKKEN: Yeah. I learned in Python 2 and the conversion to Python 3 was very painless. The only thing I was waiting for was one of the libraries that I depended on, the interactions with the LLs was a little different because of the string things. But let’s face it, Python 2 used basically C strings and they aren’t normal arrays of characters. That’s not good enough; that’s not real. The argument’s a lot contradictory to itself because the many formatting choices for strings are because we 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. Yet, one of the things that caused the break between 2 and 3 and make them not backward compatible is this decision about strings. At first I disagreed with it but after working with it for a while I totally understand the choice and it makes sense.
KENNEDY: Yeah, I don’t know what the alternative is. Sporadic run time errors? Great. C’mon. It’s one thing to say string in Python 3 suck, that’s a reasonable contention. I don’t make that myself but you could. To make that immediately 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. One does not follow from the other.
I got worked up and I was going to write up something about this. But this guy, girl, I don’t even know the gender, Evee wrote a fabulous point-by-point logical rebuttal of this and sort of a personal comment as well. We’re going to link to that, which has the original article’s quotes as well as comments about it in our show notes.
OKKEN: Yeah, and I’d like to say about anybody who’s freaked out about this at all, don’t be freaked out. It isn’t a big deal. 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.
KENNEDY: Yeah, he even said on Twitter that he was looking to move on from Python, so that’s fine. I totally respect that. I’ve moved on from other technologies to Python, actually. But don’t poison the well on your way out the door as your last act. Personally, I’m not going to recommend Zed’s book anymore. I just don’t think this is the person that should be representing the first touch with people coming into Python. Everyone else can do whatever they like.
OKKEN: Alright, I agree.
KENNEDY: Let’s talk about something newer, something in Python 3, actually.
OKKEN: Okay, well one of the things that has come up in Python 3 as our second article is the AsyncIO has changed quite a bit. In Python 3 it’s gone through several iterations. I’m not really an expert on it but there was a Reddit discussion talking an article. The article’s actually from February but the Reddit discussion is about the AsyncIO for the Working Python Developer. Actually, the article that we’ll link to I think is a pretty okay tutorial on understanding some of the different terms like futures and threads and tasks. I think it does a pretty good job. There’s a couple downsides; it does use Python 3.4 syntax and the syntax has changed. It still works in 3.5 but there is a newer Async 08 syntax in 3.5.
KENNEDY: Yeah, and that makes it much more approachable, I think. It makes the code change significantly less, from a synchronous model to an asynchronous model. Let the implementation and run time deal with that for you.
OKKEN: Yeah, but in that regard this is one of the reasons why I included it. I’d like somebody to take this type of an article and write it with the new Async 08 keywords. It would also be great if they could come up with an example that didn’t include sleep statements.
KENNEDY: A real world example would be great.
OKKEN: Yeah, so anyway. That’s my second article.
KENNEDY: If you’re looking to get into Async stuff in Python, check this one out. It’s cool. We’ll have another thing later in the show as well about Async.
My second choice here was Pyston, which is an alternate implementation of Python, as opposed to say, CPython. This actually is most notable because it’s coming from Dropbox where Guido Van Rossum and crew work. Dropbox is one of the biggest users of Python in the commercial space. It’s really a center of the Python universe. They’re working on a JIT version of Python (Just In Time compiled version) that is different than CPython. That’s pretty cool. This release is 0.6 and the main goal was to reduce the overall memory footprint. There’s a couple interesting comparisons. It’s 50% better than it was before. And in every single case the memory usage is actually better in Pyston now, it wasn’t before but now it is, compared to PyPi which is the other major active JIT implementation for Python.
They also picked up some of the Python 3.6 features like ordered dict and so on.
OKKEN: Okay, I guess I’m misunderstanding the graph. It’s still a larger memory footprint than CPython?
KENNEDY: It is still more memory than CPython because I believe it’s a reference counting Garbage Collector, though I’m not for sure. I think it’s a GC-based language. Possibly, which generally means more memory usage.
Certainly, PyPi is GC which means more memory usage. It’s interesting. I don’t think it’s really there yet. I’m not totally sure. They focused a lot on NumPy implementation and some of the scientific stuff. It’s nice to know there are many implementations of Python and here’s yet another.
OKKEN: Yeah, it would be cool. I think it’d be kind of neat if we could get somebody from the Pyston project to maybe go on your show.
KENNEDY: Yeah, I’d love to have them on Talk Python. I actually talked to them a little bit when the project was announced a year ago. I don’t believe anybody ever agreed to come on the show so I might have to follow up with that. You’re right, that would be cool. I’d have the Pyjion (Pigeon) guys on, which is the Microsoft’s version of that which is actually really cool. Some of the Python core developers are working on it; Brett Cannon and groups. I had them on my show. That was a super interesting topic.
OKKEN: Yeah, it is. I’d be interested to hear some of the motivation. If Dropbox is throwing money at it, there must be a reason why around there; it’s not that they’re just curious.
KENNEDY: There is something. They are actually not using it in production yet but maybe they’re looking to. We’ll see.
OKKEN: Yeah, okay.
KENNEDY: Before we get to the next one, I’s like to tell you about our sponsor. How cool is it that we have a sponsor already? That’s great, right?
OKKEN: Yeah, I’m very grateful to these guys.
KENNEDY: Rollbar’s awesome. I actually use Rollbar; I used Rollbar before they sponsored the show. Let me just tell you about them. So, on the Talk Python websites, across three of the sites there, they handle almost 2 million dynamic ACP requests a month and transfer upwards of 5 terabytes of data. I deploy to them several times a week. I’m not even worried about pushing them out because in addition to continuous integration, if something goes wrong – my slack, my email, my phone – everything will be blowing up with notifications from Rollbar saying, ‘Something broke. Check the server.’ And you’ll get detailed error reports whenever something’s wrong. If there is an error, you usually don’t have to debug it because all that info is right there.
You Python Bytes listeners, you can have the same piece of mind. Just visit Rollbar.com/pythonbytes, which is also in the show notes, and sign up for the free tier. Thanks, Rollbar.
OKKEN: Thank you, Rollbar. Also, while you’re there, there’s a really fun demo you can play with.
KENNEDY: Alright, let’s talk about docs.
OKKEN: I just heard about this last week. I’m not when they announced it, but there’s a website called pydoc.io and we’re going to link to the announcement. It’s on the Read the Docs (readthedocs.org) site. I forgot who’s behind this but the idea is similar to a lot of API documentation generators. It looks like they’re going to try to automatically generate documentation about the APIs for at least a whole bunch of PyPi repositories.
KENNEDY: Yeah, they said they’re starting with the popular ones. But they said eventually their plan is to autogenerate API references for every package on PyPi. That’s over 90,000 packages. That’s pretty awesome.
OKKEN: That’s kind of incredible. It may surpass all of the rest of the stuff on Read the Docs right now but I’m not sure.
KENNEDY: It’s really interesting and I’m not really sure quite how it works. Maybe it looks at the actual documentation in your Python code or whatever. Have a look. If you have a package out there and you want to make sure it shows up here, be sure to check that out.
OKKEN: A few of the packages they’ve got so far, I looked around and it looks pretty neat.
KENNEDY: I was cruising through requests that’s up there, of course.
So, we talk about things that maybe advanced people care about like converting bytes to byte strings and what not to regular strings and whatever. I found an interesting article, really a conversation that I wanted to highlight. The question was, what’s the one thing or the primary thing that took your Python experience to the next level. This was asked by a guy who’s had three months of Python and is trying to get into it. So, I picked out 5 that I thought were pretty cool.
The first one out there said what sort of changed their relationship to Python and how they wrote code was mastering generators. Another person said, ‘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 itertools.’ I find that it’s interesting in Python – another person said, ‘List comprehensions’ – how important iteration and processing streams of data is.
OKKEN: These are good.
KENNEDY: One of them I think is going to be near and dear to your heart is unit testing and Pytest in particular.
OKKEN: Yeah, I’d probably say do system-level tests first but yeah, I agree.
KENNEDY: Well, it changed this guy’s life so… (laughing)
Another person said, ‘For me, all of David Beazley’s work, in particular his work on co-routines’ which was sort of hinting at the AsyncIO stuff as well.
OKKEN: Maybe I should check that out.
One of the things I’d like to add to this is I see a lot of people that already know several languages. When they come to Python, there’s a desire to just jump in the deep end and skip over some of the basics. I think anybody that’s in that boat should go back and make sure they understand all of 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 better right off the bat.
KENNEDY: Absolutely. I think it’s one of the curses of Python’s ability to be quickly and easily learned. You don’t have to trudge through all details, you can almost just jump in right away. But you do actually overlook some it’s really beautiful nuanced aspects of it if you just have the same mindset, as say coming from C.
OKKEN: I still find people that are surprised, that have written Python for a long time, that don’t know that you can do two comparisons in an If statement. You can say, if 1 is < X is < 12.
KENNEDY: ‘I tried [py pipe] and it didn’t work so it must not be in there.’
So, when you write code like that you probably want to debug it easily, right? The best place to learn how to quickly and easily debug your code is from my dinosaur.
KENNEDY: The guy who gave the talk was wearing a dinosaur suit. So, I’m talking about Q, our friend Luciano Ramalho gave us…
OKKEN: Oh yeah, totally! You set it up for me and I just dropped the ball. I was playing baseball over in the corner.
KENNEDY: So, Luciano Ramalho tweeted out something really cool and we both picked up on it.
OKKEN: Yeah, Luciano Ramalho, by the way, way cool name. There’s a project on PyPi called Q and it’s a quick and dirty debugging output for tired programmers. There’s a link to a 5-minute lightning talk by Ping and the gist of it is a way to add logging that saves to a file and in very little code. This is something you can add even to a running web service or something. You have no idea where standard out and standard error are going and you can still add some logging to find out what’s going on.
KENNEDY: It’s really cool. What I really like about it is, you basically say… instead of log something to print something, you go ‘q.q’ and you give it an expression and make it as complicated as you want. It will actually figure out the expression, the method it’s in as well as the value and it will give you a little summary. It’s really cool.
There’s also a tracing thing so if one function’s being called with the wrong parameters and you’re like ‘Why is this happening?’ You can put ‘decorator q.t.’ on that function and it will trace the entire call stack with the name of the function, all the local that are passed and so on.
OKKEN: Yeah, and just watching him in this talk to add fairly complete logging onto a module in 20 characters they added to the file, it’s pretty cool. Definitely check it out.
KENNEDY: And a bonus because he’s in a dinosaur suit.
OKKEN: Yeah, he’s also in a dinosaur suit. One of the things I liked about it is because I’m one of those quick and dirty debuggers. I will not reach for the debuggers first, I will reach for logging, so this is good.
KENNEDY: It was really cool. It’s a 5-minute lightning talk at a PyCon, but it’s like 25 minutes. The link I put in there actually has the time stamp in it so it should jump right into his talk.
OKKEN: One of the things I liked is, it’s a decent example for giving a good lightning talk.
KENNEDY: Yeah, it was really compelling. People loved it.
That’s it for the news. You might have thought Thanksgiving was going to be dull but it was not.
Brian, what else is up with you?
OKKEN: Thanksgiving has put me behind schedule on my book. I’m going to have to take a little bit of a pause from some of the podcasts. Other than this, I’m going to keep up with this of course, and catch up with my book.
I do have some interesting interviews coming up and I’ll definitely keep those flowing whenever they come in. That’s up for me. What do you’ve got going, Michael?
KENNEDY: Not too much. I tried to catch up on a bunch of things over the downtime on break.
Also, I just have a quick follow-up from last week. We talked about how cool Python 3.6 is and that the release is coming and it was in beta. I think I forgot to mention, the expected release date of Python 3.6 according to the official page there December 16, 2016. That’s coming up in a couple weeks. We’re going to be having a shiny new Python 3.6, it’s going to be great.
OKKEN: Yeah, we’ll definitely have to include that in that week’s Python Bytes.
KENNEDY: There’s no way to avoid that. That’s going to be awesome. Looking forward to it.
It was great to chat with you and thanks for sharing all the news you found with everyone.
OKKEN: Thanks for talking with me, Michael.
KENNEDY: You bet. Bye everyone.