Python Bytes - #19 Put your Python dictionaries in a box and apparently Python is really wanted
Episode Date: March 27, 2017See the full show notes for this episode on the website at pythonbytes.fm/19...
Transcript
Discussion (0)
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. I'm Michael Kennedy.
And I'm Brian Ocken.
And we got some Python news for you. Hey Brian, how's it going?
It's going really good.
Yeah. I'm excited about what you picked out. I want to learn about the ones that you got. And I have some sort of outer loop ones that are really, really different. I think
people will be interested to hear about them. But let's start with what you got on tap.
Well, we're going to start with a story about exceptions in 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.
And it's called Better Exceptions.
And it's a hook that actually is pretty and split out everything that's in there.
And we have the link on our show notes, but there's a great picture that you can see that shows the exceptions.
Yeah.
What I like about this is that, like you you said a picture is what you have there and
we talked about peter too last week about making that sort of bland just flat list into like
something really readable and colorized and nice and this kind of does that for exceptions right
yeah it does and it was really great and um josh works he mentions and then it was, he posted it on Reddit as well. And on Reddit, he mentions that he works
only in Python 2.7. So he wasn't sure how to do Python 3 at first. And he put this together pretty
quickly and then put it out there for everybody. And immediately, the conversation on Reddit turned
to Python 3 and why isn't there Python 3 support? And one of the great things about this story is Florian, who is Paradox Zero on both on
GitHub and on Reddit, said instead of adding to the complaints list, he went out and made
it, he forked it, put in a pull request with a Python 3 fix.
And within like eight hours, the whole thing was merged and it was Python 3 as well.
Yeah.
So like eight 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?
Yeah.
And it's just really incredible.
And I actually reached out to both of them and wanted to know if they had anything to add to the story and like I was
saying Josh wasn't he didn't know how to do make sure that it was running on both because he
normally works on Python 2 and Florian apparently he supports this tool called WDB which is a web
debugger which actually we should explore a little bit later it's pretty cool anyway he's used to
doing that two and three all the time so it wasn't't that big of a jump for him to add that support, which is great.
So I like it.
Yeah, I think it's cool.
I think better exceptions, the package is really cool.
And I think the Python 3 story of eight 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.
We have to fix it.
That's really cool.
I'm not sure if that would have happened four years ago, right?
Right.
And it's really great.
The other thing, when I tried this out,
and one of the things that I noticed about it
is you have to put an import statement in the modules
that you want to use this better exceptions.
Paradox Zero also thought maybe we should modify that.
So he added another GitHub project
called better exceptions hook
that if you include that as well,
you don't have to do that import statement.
So it's pretty great.
Yeah, that's really great.
Cool.
So everyone check out better exceptions.
Check out the Reddit thread.
We'll link to that, of course,
maybe as the primary thing
and all the stuff's in the show notes. Very cool.
One 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, you know, like a hundred000 people filling out the survey or something. And it's
really comprehensive. So this year, they just released a couple days ago, the 2017 survey,
and it has good news for Python in there. Really? And it looks like they get results
from all over the world. They do. Yeah, they get a ton of results. Like I said,
they have stuff on gender equity pay across different
regions 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 so there's some good news here
for Python if you look at the most popular technologies, we talked recently about Python being the second most popular technology
behind JavaScript on GitHub.
On Stack Overflow, in terms of questions, it's number five.
And 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.
So 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- node JS, and whatever Java itself. If you look
at Python over the last five years, it went from 22% to 33%. And it's got like a hockey stick,
like curve going to it. So it's not just it's going up, it's going up in the rate is increasing.
How cool is that? That's very neat. I like it. If you compare it to Java, Java's on a pretty downward trend. C sharp is on a downward trend.
C plus plus, downward trend. So that's cool. One other one that really I like, there's a section
called most loved, most dreaded, and most wanted. So Python ranks very highly in the most loved.
And just let's see how the story is for most dreaded.
It turns out Visual Basic 6, VBA, CoffeeScript, and VB.NET,
three out of four for Visual Basic,
are in the most dreaded technologies,
just with MATLAB, TEL, and along.
But if you go over to most wanted technology,
Python, by a wide margin.
Oh, wow.
Out of everything.
That's great.
Over JavaScript, over Go, over TypeScript, over Swift, over Rust, whatever.
It's 20% of the people said, that's the thing I want most.
Who responded about that?
Isn't that cool?
What does most wanted mean?
It means if you could choose, they ask, what are you using for your day-to-day job?
And they ask, if you could use anything, what would you use?
Oh, okay.
Yeah?
Just to round it out, one 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 like more than 2x over second place.
So, also quite interesting.
Well, working with document databases is just, I like it.
If you can do it.
It's so glorious.
Yeah.
If you can make it work, it is so, so nice.
We'll have to cover that in more detail.
But 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.
It's not 100,000, sorry.
But still a huge number to make
this highly statistically relevant right yeah and we need to get more it looks like there's still
with surveys like this we still have uh more white dudes answering than other people yeah that's
that is an ongoing problem but what was it there okay so since since you brought that up i was
thinking about didn't want to go on too long But there's a section in here that talks about near the beginning.
It talks about demographics, and it says males like 88.6%, females 7.6%, white dudes are like 74%.
If you throw in Asians, it's super, super near like the top. But there's also a section somewhere 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 anything but male, female, I don't think.
But if you look at less than one year experience, there's more women than men.
If you look at one to two, there's more women than men.
It's not until you get into five years of experience that there are more men. If you look at one to two, there's more women than men. It's not until you get into five years of experience that there are more men. And then it's just after that, it's gone, right?
It's all men all the time. But that's pretty encouraging to me because that means people
coming into the industry, there's a lot of women coming in actually. So. Yeah, that is really
encouraging. That's good. Yeah. So it's right that it is kind of bleak in that sense, but there's a bit of a shining, at you just take a dictionary and throw it into an object class called box.
And what it does is it makes it so that you can use dot notation instead of that annoying.
I mean, the dictionary notation is okay, but it's like so many characters to type in the brackets and the quotes and for single word elements in your indexes in your dictionary
box makes it so you can just use dot notation instead it's it's pretty cool that is cool i am
so using box so what's really nice about it i mean it feels like it's a little bit similar to like
name tuple type things i mean i guess it's dictionaries rather than names for the tuples
but still it's like kind of like that like the tuples, but still, it's like
kind of like that.
Like you take this thing you have to index into and you turn it into a thing you can
use dot names on.
And while that's pretty helpful, what I think is really cool looking at this is you can
have like a deep object graph.
So in their example, they have a box which has movies, the movies, one of the movies
is Spaceballs.
Each individual movie has a rating and you can just say my box dot movies dot space balls dot rating and so if that was
dictionaries that would be a lot of this dot get this dot get this dot get this or bracket bracket
bracket bracket right yeah if you're trying to test each one of those then that's even
even less fun to test that it's in the in the dictionary yeah and it doesn't like obviously
i was trying trying it out like one of the movies movies that they showed in their demo was Robin Hood, Men in Tights.
Also a good movie.
Anyway, it has spaces in it.
So, obviously you can't make a dot name thing with something with spaces in it.
So, it just punts and doesn't do it for those.
So, it's only.
Right.
Okay.
Anyway.
Yeah, so those you have to basically use the brackets. Treat it like a dictionary. Yeah, but it's those. So it's only... Right. Okay. Anyway. Yeah. So those you have to basically use the
brackets, treat it like a dictionary. Yeah. But it's enough. 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. So...
Yeah. This is cool. I think the thing that's awesome about this is it makes your code more
readable. Yeah, definitely. Okay, cool. Well, thanks for teaching me about Box.
So it wasn't very long ago that we just talked about Python 3.6 being released, right?
Yeah, and very exciting.
Yeah, it's super exciting. That's a big release.
There was a lot of performance improvements, both in memory and CPU time.
And so we were already at our next release.
So on March 21st, we had Python 3.6.1 released. How about that?
That's pretty cool. I haven't tried it out yet, though.
I'm running it. It's been working well for me. It's very nice. There are actually a surprising
number of changes given the timeframe between 361
and 360 being released. So there's a lot of fixes.
There's probably 25 fixes and
optimizations for core and built-in. If you look at the library, there's
probably 35 to 40 fixes.
Things like there was some kind of bug in argpars that help messages would wrap on non-breaking
spaces and other funky stuff like that. Fixes to the magic mock library. So what struck me about
this release is like a 361 release feels like you got 360 six, one, whatever. It's all the same, right?
But there's actually a non-trivial number of things that I might actually want to go
and say, oh my gosh, we need to upgrade to this.
So for example, another one is fixes a crash when deallocating deep element tree objects.
So if you load up large XML files and are having problems with that, maybe you want
to look at this.
There's also sections on windows on on the C API, and lots of stuff.
The other thing that's interesting or notable about this is, I don't know if 360 or 361,
but one of those two recent releases is the first time that Python is shipping off of GitHub since it's moved off of Mercurial.
Okay.
So that's pretty cool.
I think so, anyway.
I think so.
I'm pretty sure that 365 was on the other one.
I can't find which one it is in here,
but some of the core developers
seem to be very excited about F-strings
now with the 3.6.1.
So there must have been some issue with it
that we just don't even know about
that now makes them work better or something.
Yeah. The only one I can find is F string expressions are no longer accepted as doc
strings. You know, that might be it. Maybe somehow the F strings in doc strings were
being interpreted when they were supposed to be documentation. Like here's the F string to use.
I don't know.
It's great.
If you get a chance, upgrade to 361.
I will. Well, last I've got a, I I've got to tell a little bit of a story.
I went to the University of Oregon, and I tried to take statistics in a building called D.D. Hall.
And D.D. 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. And it was like on maybe the third floor, had to walk upstairs, little tiny room, and four
o'clock in the afternoon with air conditioners blowing. And the gist of it is, is I didn't learn
statistics. I was slept through that class. And so I'm excited that there's a,
an article called, and it looks like it's a start of it. It's called essential statistics for data
science. So it's teaching some of the Python data science stuff along with, and how to use
statistics with it, but also teaching you about the statistics while it's going.
And I really appreciated that. And it was really easy to follow even for somebody that slept
through statistics. So, you know, data science is actually one of the reasons I think for that,
that growth in the Stack Overflow section, I was talking about others as well, right? But I think
the addition of all these data scientists moving into the space makes such, such a big difference.
So there's a lot of people coming into the space makes such a big difference.
So there's a lot of people coming into the space and really having a good statistical foundation, I think, is super important here.
In this article, this tutorial, it also explains the box and whisker diagrams and what all of those pieces mean, which I had no idea what those meant before.
So thank you.
Okay.
Yeah. Yeah, that's awesome. Anyway, so thank you. Okay. Yeah. Yeah. That's awesome. Anyway. Cool. That's all I got.
Yeah. Okay. Well, the last one that I want to talk about is called high HY. And for those of you out there that like Lisp, this will be music to your ears. So the idea is high is a Lisp
environment, scheme Lisp type thing. And 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.
Okay.
So we've talked about all sorts of different runtimes or interpreters.
We have the two CPython versions.
We have PyPy.
We have Python.net.
We have Jython.
We have IronPython.
We've got Cython.
There's lots of different choices you can make, but I've never talked about Hi.
And this was actually a listener recommendation.
So thanks for sending that in, guys.
So this is if you write Lisp code, you can write code in Lisp, and then 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 the PyPI packages
for your Lisp programs, which I think is pretty awesome. So if you want to work with various
libraries, requests, it says you can write Django applications in Lisp.
If that seems like a good idea, you can use HIDA to do that.
Probably Flask and Pyramid as well, I guess,
because you just import it, right?
Yeah.
So, yeah, they think it's a great way for people to explore Lisp
if you are comfortable with Python.
Now, do something for me.
Click on the link that says you must try,
try-hi.appspot.com and
just tell me what you think when you see that oh that's cool right so you guys all check this out
when you hear this uh click this link in the show notes it's what version of apple is that it's not
even apple it's a it's but it looks a little bit like an apple 2e computer oh that's so cool it's
a little tiny old crt and you can type on, like when you type in, you get to type right on this little monitor. It's cool.
It's fantastic. It's even at an angle and you get to type into the interpreter and it's live and you can try out Lisp. My Lisp is not good enough, but I can at least hit enter and see 42L come out. So check this out. This is really pretty interesting if you're into Lisp. If you're not into Lisp, I think it's just an interesting data point of here's one more thing,
one alternate way to get other languages in the Python ecosystem.
Yeah, I just tried out the extent of my Lisp knowledge that cons makes a tuple.
Nice.
I've forgotten all about the cutter in the car and all that stuff from when I took it back in school.
It's been a long time.
It's been a long time. It's been a long time.
It has.
All right.
Well, that's it for the news this week, everyone.
Thanks, Brian.
You found some good ones.
Thank you.
One last thing I want to do a little bit of follow-up.
Last week when we covered PDR2, I commented that it didn't look that great in PyPI.
And that was fixed last week.
And with one of the best pull requests I've ever seen
or comments in the code,
and the comment was, remove beer from readme.
Apparently there was a beer Unicode symbol
that was messing up the PyPI stuff.
So that's good.
It's marked as a bug and urgent
that we get the beer out of the readme. Fantastic.
That is awesome. All right. Yeah. Cool. So that's, it's pretty neat that that actually,
uh, that people listen to our show and change the projects based on it, right? That's, that's
awesome. Yeah. Or they, they may have noticed it on their own, but let's go with that. They're
listeners that they took your advice and remove the beer. Excellent. All right, well, thanks so much for chatting with me, Brian,
and sharing the news with everyone.
It's fun as always.
Thank you.
Yep, bye.
Thank you for listening to Python Bytes.
Follow the show on Twitter via at Python Bytes.
That's Python Bytes as in B-Y-T-E-S.
And get the full show notes at PythonBytes.fm.
If you have a news item you want featured,
just visit PythonBytes.fm and send you have a news item you want featured, just visit
pythonbytes.fm and send it our way. We're always on the lookout for sharing something cool.
On behalf of myself and Brian Ocken, this is Michael Kennedy. Thank you for listening
and sharing this podcast with your friends and colleagues.