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


« Return to show page

Transcript for Episode #19:
Put your Python dictionaries in a box and apparently Python is really wanted

Recorded on Sunday, Mar 26, 2017.

00:00 KENNEDY: Hello and welcome to Python Bytes. This is Episode 19 where we’re going to deliver Python news and headlines directly to your earbuds. It’s recorded on Sunday, March 26, 2017.

00:00 Michael Kennedy.

00:00 OKKEN: And I’m Brian Okken.

00:00 We’ve got some Python news for you.

00:00 Brian. How’s it going?

00:00 It’s going really good.

00:00 I’m excited about what you picked out. I want to learn about the ones you got and I have some sort of outer loop ones that are really different. I think people will be interested to hear about them.

00:00 start with what you’ve got on tap.

00:00 We’re going to start with a story about exceptions and Python 3. Not exceptions in Python 3. But there is a person named Josh, or Quix on GitHub, who wrote a little utility for Python which is actually really cool. It’s called “Better Exceptions.” It is just a hook, but actually it’s pretty clever. It hooks in to your exceptions so when you’re developing and debugging or dogfooding your own products, it will show exceptions that are color-coded and split out everything that’s in there. We have the link on our show notes, but there’s a great picture that you can see that shows the exceptions.

00:00 Yeah, what I like about this is that, like you said, a picture is what you have there. We talked about pdir too, last week about making that sort of bland, flat list into something really readable and colorized and nice. This kind of does that for exceptions, right?

00:00 It does and it was really great. Josh posted it on Reddit as well. On Reddit, he mentions that he works only in Python 2.7 so he wasn’t sure how to do Python 3 at first. He put this together pretty quickly then put it out there for everybody. Immediately, the conversation of Reddit turned to Python 3 and why there isn’t Python 3 support. One of the great things about this story is Florian, who is paradoxxxzero on GitHub and Reddit, said that instead of adding to the complaints list, he went out and forked it. He put in a pull request with a Python 3 fix and within 8 hours the whole thing was merged and it was Python 3, as well.

00:00 Yeah, so like 8 hours of the thing being announced it came out without Python 3 support, the community went in and added Python 3 support. Something like this, right?

00:00 Yeah. It’s incredible. And I actually reached out to both of them because I wanted to know if they had anything to add to the story, and like I was saying Josh didn’t know to make sure it was running on both because he normally works on Python 2. And Florian, apparently, he supports this tool called WBD (Web Debugger), which actually we should explore a little bit later. It’s cool.

00:00 used to doing that, 2 and 3, all the time so it wasn’t that big of a jump to him to add that support; which is great. I like it.

00:00 Yeah, I think it’s cool. I think better_exceptions, the package is really cool. And I think the Python 3 story of 8 hours from the time it was published, somebody went and said, ‘There’s a problem with this. It doesn’t support Python, it only supports Legacy Python. You have to fix it.’ That’s really cool. I’m not sure that would have happened 4 years ago, right?

00:00 Right. It’s really great. I tried this out and one of the things I noticed about it is, you have to put an import statement in the modules that you want to use this better_exceptions. Paradoxxxzero also thought, ‘Maybe we should modify that.’ So, he added another GitHub project called better_exceptions hook. If you include that as well, you don’t have to do the import statement. It’s pretty great.

00:00 Yeah, that’s really great. Cool, so everyone check out better_exceptions. Check out the Reddit thread; we’ll link to that as the primary thing, and all that stuff’s in the show notes. Very cool.

00:00 of the things I always look forward to, Brian, is the Stack Overflow Developer Survey. Stack Overflow is such a powerhouse in the software space and they get quite a bit of feedback on their surveys; like 100,000 people filling out the survey. It’s really comprehensive.

00:00 year, they just released a couple days ago, the 2017 Survey. It has good news for Python in there.

00:00 Really? It looks like they get results from all over the world.

00:00 They do, yeah. They get a ton of results, like I said. They have stuff on gender equity pay across different reasons, job demand, all sorts of stuff like that. But the most interesting thing to me is really around the programming languages that are being used, or desire behind working with certain technologies and so on.

00:00 there’s some good news here for Python. If you look at the most popular technologies, we talked recently about Python being the 2nd most popular technology behind JavaScript on GitHub. On Stack Overflow, in terms of questions, it’s number 5. Given that it’s pretty easy to work with relative to things like Java, which might generate more questions, I think that’s pretty interesting.

00:00 Yeah.

00:00 That’s cool, but let’s go down a little bit farther. They have areas where they talk about the frameworks you’re working with, the databases that people are using, platforms. But one of the things that caught my attention is languages over time. So, we’ve got things like C Sharp, JavaScript. Objective C, Node.js, Java itself. If you look at Python over the last 5 years, it went from 22% to 33%. It’s got like, a hockey stick curve going to it. It’s not just going up, it’s going up and the rate is increasing. How cool is that?

00:00 That’s very neat.

00:00 If you compare it to Java, Java’s on a downward trend. C Sharp is on a downward trend; C++, downward trend. That’s cool.

00:00 other one that I really like, there’s a section called, “Most Loved, Most Dreaded and Most Wanted.” Python ranks very highly in the “Most Loved” and let’s see how the story is for “Most Dreaded.” It turns out Visual Basic 6, VBA (Visual Basic for Applications), CoffeeScript and VB.net – 3 out of 4 for Visual Basic – are in the “Most Dreaded” for technologies, with MATLAB tailing along.

00:00 you go to “Most Wanted Technology”, Python by a wide margin. Out of everything. Over JavaScript, over TypeScript, over Go, over Swift, over Rust; 20% of the people who responded said, ‘That’s the thing I want most.’

00:00 What does “Most Wanted” mean?

00:00 It means, if you could choose. They ask, “What are you using for your day-to-day job?” and “If you could use anything, what would you use?”

00:00 more thing, since I’ve been going on and on about Mongo and stuff like that recently. If you go to the database section and look at the “Most Wanted Database”, MongoDB is more than 2 x over 2nd place. Also, quite interesting.

00:00 Well, working with document databases, I like it. If you can do it…

00:00 Yeah, if you can make it work, it is so nice. We’ll have to cover that in more detail. I strongly encourage you guys to go and have a look at this survey; it’s always really insightful. They had 64,000 developers in this response, not 100,000, sorry. But a huge number to make this highly statistically relevant.

00:00 Yeah, and with surveys like this, we still have more white dudes answering than other people.

00:00 Yeah, that is an ongoing problem. Since you brought that up, there’s a section in here near the beginning that talks about demographics and it says male is like 88.6%, female is 7.6%. White dudes are like, 74% and Asians are super near the top. But there’s also a section in there that talks about years of coding experience and demographics over time and they break that down. They don’t break it down by male/female but if you look at ‘Less than 1 year experience’ there’s more women than men. If you look at ‘1 to 2’ there’s more women than men. It’s not until you get into ‘5 years of experience’ that there are more men. After that, it’s gone; it’s all men, all the time.

00:00 that’s pretty encouraging to me, because it means people coming in to the industry, there’s a lot of women.

00:00 Yeah, that is really encouraging.

00:00 It’s right that it is kind of bleak in that sense, but there’s a bit of, at least, a positive data point there. I think that’s great.

00:00 do you have next for us?

00:00 I’ve got a project called, “The Box.” There was an article on Code Calamity; that’s a cool name. This is a pretty simple tool; you just take a dictionary and stick it in a class called, ‘Box.’ What it does it makes it that you can use dot notation. The dictionary notation is okay, it just takes so many characters to type and the brackets and the quotes. For single word elements in your indexes in your dictionary, Box makes it you can use dot notation instead. It’s pretty cool.

00:00 Oh, that is cool. I am so using Box.

00:00 what’s really nice about it is it feels like it’s a little bit similar to namedtuple-type things. I guess it’s dictionaries rather than names for the tuples, but still… It’s kind of like that. You take this thing and you have to index it to and you turn it into a thing that you can use .names on. While that’s pretty, what I think is pretty cool-looking is you can have a deep object graph. Their example is a box that has movies, one of the movies is Spaceballs. Each individual movie has a rating; you can just say mybox.movies.spaceballs.rating. If that was dictionaries, that would be a lot of this.getthis.getthis or [bracket] [bracket], right?

00:00 Yeah.

00:00 If you’re trying to test each one of those, that’s even less fun to test that it’s in the dictionary.

00:00 Yeah. Obviously, I was trying it out. One of the movies they showed in their demo was Robin Hood: Men in Tights, also a good movie. It has spaces in it. Obviously, you can’t make a .name thing with spaces in it, so it just punts and doesn’t do it for those.

00:00 Right. Those you have to use the brackets, treat it like a dictionary.

00:00 Yeah, but anything that saves me a little bit of typing and makes my code look a little cleaner, I’m going to give it a try.

00:00 Yeah, this is cool. The thing that’s awesome about this is that it makes your code more readable.

00:00 Definitely.

00:00 Okay, cool. Well, thanks for teaching me about Box.

00:00 it wasn’t very long ago that we just talked about Python 3.6 being released, right?

00:00 Yeah, very exciting.

00:00 It’s super exciting. It’s a big release, there’s a lot of performance improvement both in memory and CPU time. So, we’re already at our next release. On March 21st, we had Python 3.6.1 released. How about that?

00:00 Cool. I haven’t tried it out yet though.

00:00 I’m running it. It’s been working well for me; it’s very nice. There are a surprising number of changes, given the timeframe between 3.6.1 and 3.6.0 being released, so there’s a lot of fixes. There’s probably 25 fixes and optimizations for core built-in. If you look at the library, there’s probably 35 to 40 fixes. There was a bug in Argparse that help messages would wrap on non-breaking spaces and other funky stuff like that. Fixes to the MagicMock library.

00:00 struck me about this release, the 3.6.1 release feels like, ‘You’ve got 3.6.0; it’s all the same.’ But there’s actually a non-trivial number of things that I actually want to go and say, ‘Oh, my God. We need to upgrade to this.’ For example, another one is, “Fixes a crash when deallocating deep element tree objects.” So, if you loaded up an XML files and are having problems with that, maybe you want to look at this. There’s also sections on Windows, on the C API; there’s lots of stuff.

00:00 other thing that’s interesting or notable about this – I don’t know if it’s 3.6.0 or 3.6.1 – one of the 2 recent releases is the first time that Python is shipping off of GitHub since it’s moved off Mercurial. That’s pretty cool. I think so, anyway. I’m pretty sure that 3.5 was on the other one.

00:00 I can’t find which one it is in here but some of the core developers seem to be very excited about f-string now with 3.6.1. There must have been some issue with it that we just didn’t even know about that now makes them work better or something.

00:00 Yeah, the only one I can find are, “F-string expressions are no longer accepted as doc strings.” That might be it. Maybe somehow the f-strings in doc strings were being interpreted when they supposed to be documentation, like, ‘Here is the f-string to use.’ I don’t know. If you get a chance, upgrade to 3.6.1.

00:00 I will.

00:00 I’ve got to tell a little bit of a story. I went to the University of Oregon. I tried to take statistics in a building called Deady Hall. Deady Hall was built in 1873 to 1876, so it’s a really old building and I think my professor may have been born at the same time, because he was a really old guy. It was on the 3rd floor and I had to walk upstairs, little tiny room, 4 o’clock in the afternoon with air-conditioners blowing. The gist of it is, I didn’t learn statistics; I slept through that class.

00:00 I’m excited that there’s an article called, “Essential Statistics for Data Science.” It’s teaching some of the Python data science stuff and how to use statistics with it, but also teaching you about statistics while it’s going. I really appreciated that. It’s real easy to follow for somebody that slept through Statistics.

00:00 Data Science is actually one of the reasons, I think, for that growth in the Stack Overflow section I was talking about. Others as well, right? The addition of all these data scientists moving into this space makes such a big difference. So, there’s a lot of people coming into the space and really having a good statistical foundation, which I think is super important here.

00:00 In this article, this tutorial that also explains the Box and Whisker diagrams and what all of those pieces mean, which I had no idea what all of those meant before, so thank you.

00:00 Yeah, that’s awesome. Cool.

00:00 last one that I want to talk about is called Hy. For those of you out there that like Lisp, this will be music to your ears. The idea is that Hy is a Lisp environment, scheme, Lisp-type thing. You can take it, give it Lisp code and it will actually take that code and compile it or assemble it into Python abstract syntax trees, and then just hand it off to Python to execute.

00:00 talked about all sorts of different run times or interpreters. We have the 2 C Python versions. We have PyPi, we have Python.net, we have Jython, we have Iron Python, we’ve got Cython… there’s lots of different choices you can make. But I’ve never talked about Hy. This was actually a listener recommendation, so thanks for sending that in, guys.

00:00 you write Lisp code, you can write code in Lisp and it just runs on top of Python which is cool because it means that you basically get access to the entire standard library and all that the PyPi packages for your Lisp programs, which I think is pretty awesome. If you want to work with various libraries, requests; it says you can write Django applications on Lisp, it seems like a good idea. Probably Flask and Pyramid as well, if you import it. It’s a great way to explore Lisp if you are comfortable with Python.

00:00 do something for me. Click on the link that says you must try: try-hy.appspot.com. Tell me what you think when you see that.

00:00 Oh!

00:00 That’s cool, right? You guys all check this out when you hear this. Click this link in the show notes.

00:00 version of Apple is that? It’s not even Apple, but it looks like an Apple 2E computer.

00:00 Oh, that’s so cool. It’s a little tiny CRT and when you type in, you get to type right on this little monitor. That’s cool.

00:00 It’s fantastic. It’s even at an angle and you can type into the interpreter and it’s live. My Lisp is not good enough, but I can at least hit enter and see 42L come out.

00:00 this is out. This is pretty interesting if you’re into Lisp. If you’re not into Lisp I think it’s an interesting data point of, ‘Here’s one more way to get other languages in the Python ecosystem.’

00:00 I just tried out the extent of my Lisp knowledge, that Cons makes a tuple.

00:00 Nice. I forgot about the Cutter and the Car and all that stuff from when I took it back in school. It’s been a long time.

00:00 It’s been a long time.

00:00 It has. (Laughing)

00:00 it for the news this week. Thanks, Brian. You found some good ones.

00:00 Thank you. One last thing, I want to do a little bit of follow up. Last week when we covered pdir2, I commented that it didn’t look that great in PyPi and that was fixed last week. One of the best pull requests I’ve ever seen or comments in the code. The comment was, “Remove beer from readme.” There was a beer unicode symbol that was messing up the PyPi stuff. So, that’s good.

00:00 It’s marked a s bug and it’s urgent that we get the beer out of the readme. Fantastic. That is awesome. It’s pretty neat that people actually listen to our show and change their projects based on it.

00:00 Yeah, they may have noticed it on their own, but let’s go with that they’re listeners.

00:00 They took your advice and removed the beer. Excellent.

00:00 thanks so much for chatting with me Brian and sharing news with everyone. It’s fun as always.

00:00 Thank you.

00:00 Yep. Bye.

00:00 you for listening to Python Bytes. Follow the show on Twitter via @pythonbytes and get the full show notes at pythonbytes.fm. If you have a news item you want featured, just visit pythonbyes.fm and send it our way. We’re always on the lookout for sharing something cool. On behalf of myself and Brian Okken, this is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page