Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 77, recorded May 12, 2018.
I'm Michael Kennedy.
And I'm Brian Otkin.
And we have a very special episode and a live audience.
That's right, we're recording live from PyCon.
Thank you everyone for being here and everyone who couldn't make it.
You missed a great party.
This episode is brought to you by Datadog.
They actually, I think they have a booth out there?
Yeah.
Yeah, I think they have a booth out there.
I've been stuck at my booth the whole time, which is wonderful, but I don't know what's out there.
So that's amazing.
We'll tell you more about them later.
Right now, Brian, what do you got for us?
I have a fun article that actually comes from the Java world, but it's why senior devs write dumb code.
And it starts out with a quote from Kent Beck, which I love, is any fool can write code that a computer can understand.
Good programmers write code that humans can understand.
Just some tips to make sure that you try to keep clean, straightforward, obvious code.
And follow principles like Yagni, single responsibility, dry, etc.
And I think this is important in the Python world because there are some cool language features that we have that are fun to play with.
And I definitely want people to go ahead and try all the cool new language features, but make sure that your code still is readable, even by people that aren't as Pythonic savvy as you are.
That's awesome.
Are you telling me that the shortest code is not the most readable, always?
Yes.
That's hard for me to do also because I really like one-liners that pack in a whole bunch of stuff.
Yeah, I do too.
So does that cover the solid principles, like single responsibility, open-close principle, or is it just more general, like write good code?
Well, I think may write readable code.
Readable code, right.
I don't necessarily adhere to solid being readable.
You know, that's a really good point.
So like solid principles, I don't know if you all know, it's single responsibility principle, open-close principle, list-cost substitution principle, etc.
And a lot of times that is like super design pattern heavy, and you're like, there's so much abstraction here.
Like, I know this looks like it came out of a textbook, but it's bad, right?
Yeah.
So actually, maybe not so much.
Well, and I've seen it in code reviews, too.
We've had people do like maybe a C-ism in Python.
And sometimes that's bad, but also sometimes if you can look, if it's a little bit of code and you can look at it, it's easy, obvious what it's doing.
Maybe it doesn't need to change to be more Pythonic.
Yeah.
It's probably fine.
That's true.
So, Brian, have you been having a hard time finding your way around here?
Yeah.
You got lost?
You guys having a bit of a hard time?
I feel like I've taken like a walk where it's like, okay, we've gone like a quarter mile, and there was a door to that place on the other side of the expo hall.
Why didn't I go that way, right?
Well, the next thing, if they had used it, I'm sure they haven't, if they'd used it, there's this thing called GeoAlchemy 2.
You've heard of SQLAlchemy, right?
Yeah.
So there's this thing you can layer upon SQLAlchemy called GeoAlchemy 2.
And what it does is it provides geospatial queries and operations on top of, say, Postgres.
So you can ask questions like, how far is it from here to there?
Like, am I within this room?
Like, you could easily define all these as polygons, insert them as SQLAlchemy objects, and ask questions like, who is in such and such room if we all say RFID?
And that would be easier to navigate, Python?
If we could throw some A-star algorithms to, like, say, find the shortest path through all the open doors and stuff, yeah, it'd be easier.
Anyone out there do any, like, geospatial queries, things like that?
Yeah?
Yeah, not that query so much, but we do some geospatial work, and so sometimes you need to, you know, give it an object, find it in Europe.
Nice.
Have you tried GeoAlchemy?
No, I haven't.
Actually, I wanted to ask.
Is that from the same people who bring SQLAlchemy?
I think it's a different group.
There was a thing called GeoAlchemy, and then you could use that, and this is like a reimagining of the API, so this is like a second edition.
So the way it works is basically, just like SQLAlchemy, you connect to your database, you declare mapping, you declare, like, the class that just arrives from, like, a SQLAlchemy base.
It has a name and an ID, but it can also have columns like a geometry, which is a polygon, and then about that, you can ask questions.
Like, you can go to it and just say session.query.filter where this thing contains this point, or where the area is greater than or less than such and such, and just all sorts of interesting questions.
So if you like SQLAlchemy, and you want to ask questions about physical stuff, boom, GeoAlchemy 2.
Nice.
Yeah.
Well, since we didn't share each other, we have no cool segue between everything.
Not too much, but I can see what you got here for this one.
Yeah.
Yeah, so we've been on a rant, haven't we?
A UI rant?
Yes, a little bit of UI in the podcast.
But one of the things that has come to our attention is Qt is not staying still.
So there's, what I'm talking about here is there's another PySide 2, which is going to be called, like...
Qt for Python?
Qt for Python.
But it's not quite ready yet, but there's actually a lot of Python bindings that I know of.
There's PySide 2, there's PyQt 5, there's PyQt 4, there's the original PySide, and there's a couple...
And then there's Qt.py.
And this is just for Qt, not WXPython, not all the other stuff, right?
Yeah, just for Qt.
And there's two projects.
Qt.py convert is a project that converts these interface bindings to an intermediate, which is a shim layer, which is Qt.py, which is a minimal...
You can build it as a minimal Python 2 and 3 shim around all of the Qt bindings.
And just sort of fun to be able to use one, whatever you've got now, and convert it back and forth.
I think it's a great idea.
So you...
It's going to be awesome that there are new, better ways to write Python UIs.
But there's all this other code that people have written, PyQt 4, for example.
And this thing will let you sort of run a converter across it to adapt from all these different older versions to the new hotness.
So it should make it work really well.
Yeah, and one of the neat things about this is it uses a conversion that leaves all your comments in place.
So it rewrites Python code, but it rewrites it.
It leaves a bunch of your stuff in there.
That's pretty advanced.
Yeah.
So maybe do like a branch or something before you do that.
Yeah, probably.
All right.
Anybody got a comment on Python UIs?
All right.
No.
All right.
Cool.
So I'm really excited for that.
I'm excited for Python for Qt coming.
I think that's going to be good.
There's a bunch of other stuff.
I think there needs to be more work done there, as I've said.
All right.
So let me tell all the listeners and you guys about our sponsor.
So Datadog, who are big supporters of the Python space.
They're here at the conference.
Obviously, they've been supporting the show for a long time.
So check out Datadog.
They're like a monitoring solution, mostly for your distributed application.
So if you've got like microservices and containers and all that, you can trace a request from one part to the next and the next and figure out where things are slow, where you run into errors, all sorts of stuff like that.
So get a cool Datadog t-shirt.
Go to pythonbytes.fm/Datadog.
Do the tutorial.
Get a cute dog shirt.
It's awesome.
All right.
So, Brian, we live in a pretty laid back city, Portland.
It's pretty chill, right?
Love it.
Yeah, I love it too, man.
But even in Portland, there is a bit of a sense of people are like working really hard and it's almost like a badge of honor.
Like, oh, man, how are you doing?
I'm so busy.
You wouldn't believe how busy I am.
I know you're busy, but I'm like way more busy.
I've got all these projects and I've got this stuff going on and that.
There's this great article written that is a reminder that you don't have to be a workaholic to get ahead in tech.
So the article is called You Don't Have to Be a Workaholic to Win 13 Alternative Ways to Stand Out.
And I really, really like this because I feel like there's two things going on that I don't like.
One is this is what I kind of opened with.
People like busy brag.
Like it's cool to them to be super busy.
Yeah.
And so they just tell you how busy they are and, you know, we just one up each other.
Yeah, I ran into this guy that's just like, yeah, I've got two podcasts.
I wrote a book.
Yeah.
That's not cool, man.
That's not cool.
And the other one is like actual tech companies or other companies that are like, you know what?
We're going to put just a fake deadline here six weeks out and make everybody work overtime so we can hit it.
And there's like, well, what happens if we don't hit it?
Well, then my manager will be upset.
Like that is not a real deadline, right?
Those are not actual deadlines.
And so there's just a bunch of great ideas in here.
So let me run by you.
See if you think.
Oh, by the way.
Yeah.
Let me just run through the tips.
Hold on.
This thing like popped up, Anthony.
All right.
So here's the tips.
The first one is like you can be a workaholic or you can be creative.
And if you really try to think differently about solutions, if you're the person that says, yeah, we could work all night and we could build this thing this way.
Or did you know you can pip install a thing that did this, right?
If you just like think outside of the box and try to solve a solution, like creativity could be more value than working hard.
Yeah?
Yeah.
Stubbornness.
Stubbornness is not generally considered a good thing.
But in programming, like I've had lots of people go, Michael, you're so good with computers.
You're such a good programmer.
How did you learn this?
It's like I tried this.
It was hard.
It didn't work.
I'm just like, well, I tried it for three hours and then it did work, right?
Like I tried everything I could think of until it worked and it just wasn't going to quit.
And that's one of the things they're talking about.
You have that experience?
So that's a way to work less?
No, that's not a way to work less.
But what they're saying is if you're the person that like can actually solve the problem because you don't give up on it rather than just like, ah, we can't do this thing.
We've got to do something else.
Okay.
You know, that kind of thing.
They're all like pretty interesting little takes.
Curiosity.
Yeah.
Right?
Like I'm willing to like be the person that learns Kubernetes and actually now we can all go home because
our deployments don't break and I don't even have a pager.
It's amazing.
Right?
That's cool.
Kindness.
I really like the kindness one.
Like if everyone is a jerk and you're the person that's nice and helps everyone, right?
Like all of a sudden you become the person in the office or the company and they're like, yeah, go talk to Jeff, man.
He will help you and he won't insult you at the same time.
Planning.
Planning is good.
Improvisation.
Like sort of the opposite of planning.
Like, well, things aren't going to accord in plan.
Let's fix it.
Enthusiasm.
Kind of like kindness.
Communication.
That's good.
Presence.
I really like that one.
Yes.
Right?
Like so many people are like, yeah, that's a great idea.
Yeah, I'm going to go work on my thing.
Right?
But just like take the time to like be in the moment.
That's actually hard.
It's hard.
I'm making fun of it, but it's hard.
And especially in a work environment, you've got – you're like in the middle of something.
Somebody comes over.
If you're going to be interrupted anyway, then really be interrupted and pay attention.
Yeah, exactly.
Yeah, yeah.
For sure.
So I'll keep going just a little bit more collaboration, right?
Open source.
Like we're all kind of in that space.
Anyway, willingness.
Honestly, I forget what that is about.
But I remember it was really good.
Patience also.
And then finally, institutional knowledge, right?
Like –
Where to lock people up.
Yeah, where the bodies are buried.
No, like why do we have that old server over there?
And like can anybody work with it?
Yeah, actually, I know where the source code is and I could fix that for you, right?
Yeah.
I don't want to.
It's PHP.
But I could fix it if I had to.
Right.
Anyway, like so do these resonate with you guys?
Yeah.
It makes me think of, Brian, you had Stephanie.
I'm forgetting her last name.
Herbert.
Yeah.
And she talked about – I mean, your conversation over there was about mentoring, but she talked
about her worker approach and how she only works like four hours a day.
She goes around like data compression and consultancy.
But this also makes me think of a post I've seen from somebody who works with Starbucks'
web applications group.
And it talked about how they pretty much almost burned out of the tech industry.
And they just – that AI instituted some of these principles to just make things – obviously,
probably not only more productive at work, but just more sustainable for you long-term
on a personal basis.
Yeah.
That's great.
Yeah, absolutely.
All right.
So are we going back to World War I?
No, we're actually going back to QT.
Oh, okay.
So pretty much the trenches?
Yeah.
So actually, we – just related to that, when I was researching for the QT PyConvert, I was
curious as to how they did the conversion while leaving the code comments in place.
So I followed the rabbit hole.
And there's a project called Red Baron, which I hadn't heard of before.
But it calls itself a FST, which is a full syntax tree.
So it's a lossless abstract syntax tree thing, which you can do queries and modifications.
And I think it's – they've got a few uses that they list of possibly like renaming a variable in a source file and making sure that it doesn't clash with anything that's not a variable,
like not clashing with things and strings and other bits.
A few handful of like splitting up files.
There's other – I think this is sort of maybe a tool to build other tools with.
I can't imagine like – I personally wouldn't try to like write a script of like doing this.
But if I built it into an ID or something like that.
Yeah.
This sounds like this is like the foundation of a refactoring tool.
Yeah.
Pretty much.
That's awesome.
But there's no off-the-shelf thing that's going to do that.
But maybe something like this is like –
Yeah.
That's really, really awesome.
But it's a fun project.
Michael, you joke about like the conversion of two to three, but that's exactly what two to three, the tool does.
Yeah.
No.
Yeah.
So like everyone here knows the AST module, I hope.
It's really cool.
And then I guess they call it a full syntax tree, but it's often more broadly I refer to it as a CST or concrete syntax tree.
Okay.
Nice.
And so that's what two to three is based on.
That's also what the new black code formatting tool that they're going to talk to us today is based on.
Right?
Because it has to maintain comments and all these things that otherwise go away with AST.
Right.
That's awesome.
Yeah.
Thanks for that.
Yeah.
Black is awesome.
We covered it before.
You've got to like the color.
All right.
So I want to close out the official items with something pretty cool here.
So our booth is right next to the Beware guys.
And the Beware guys are trying to fill another major hole that I see in the Python space, which is really around packaging and especially mobile.
Right?
Like they're trying to build native apps in Python.
And I've been a little bit of a – I've criticized them a little bit previously saying, you guys, there's like not really many demos.
There's not a lot of screenshots.
You've got to like show me where this stuff is if you expect people to use it.
Right?
Well, so one of the announcements this week is that Project Beware just launched an app in the Apple App Store.
Like a straight up approved by Apple, installed on your phone, and it does stuff.
It's not super advanced.
It's basically like gives you currency conversions and tip calculations.
Like how much do I need to tip in like RMB?
You know, things like that.
But it's really cool that there's an example of a Beware app in the App Store.
Yeah.
Is it up on the source code?
I'm sure that it is.
I haven't looked at the source code, but yeah, I'm sure that they've got it up there.
So the link I have, I think, either goes to an article or straight to the App Store.
And it's pretty cool.
So it uses Briefcase and Toga.
And Briefcase is a tool for converting a Python project into a standalone native app on Mac, Windows, Linux, iPad, iPhone, Android, Apple TV, and tvOS.
Actually, are those different?
Anyway, yeah.
Apple TV and tvOS.
Awesome.
So it's pretty cool.
So it's like a first step.
I was talking to Keith Russell McGee about it, and he's pretty excited, but it's just the first step.
But if you guys are looking to contribute to open source, they're really, really big at accepting new folks.
They're a really great project for that.
And you get a token.
And you get a cool token, like a token to say I contributed to the Beware project.
Yeah.
I was actually talking with Ken.
Russell.
Yeah.
And he was one of the things that I, one of the parts of their system is Cricket, which is a testing GUI.
And it doesn't handle pytest, but that's one of the things they'd like to have somebody work on is to try to convert.
Oh, are you going to add pytest to Cricket?
I'll look into it, but I'm bringing this up now to recruit anybody else that wants to help out with that.
Because I would definitely try it out more if it already had a pytest link.
Yeah, that's awesome.
Yeah, you gave your talk on visual testing with PyCharm, which is awesome.
And it's going to be on one something I'm going to mention in a second.
But that's sort of another analogous thing, right?
Like a GUI for running your tests and your project.
Yeah.
So we use PyCharm for the test runner part.
But this would be just a standalone test runner without an IDE.
Yeah, exactly.
No editing, just the running.
Yeah.
Right.
It's easier to fix a test if you don't have to edit it.
All right.
Well, I think that's it for all of our items that we have for you guys this week.
I have a few extra things I want to throw out.
Actually, this one more and more to the listeners.
So first of all, all the videos, except for things like this, are recorded and put online.
So already the videos from PyCon 2018 are live, and people can check them out, right?
There's some.
Yeah, not all of them, but they're coming in.
There's a day or two latency there.
That's pretty good, though, for video.
So just go to youtube.com slash PyCon 2018.
The other one is not so good.
Apparently, there was some package that caused some trouble.
Like previously, remember we talked about there being bad packages getting into the PyPI?
So there's some Reddit post that says,
Hey, guys, you should be a little bit careful with the SSH-decorator package.
And it says, Don't install it or use it from pip.
It has a backdoor to steal all your SSH credentials.
Oh.
And if that's true, you should not have this running anymore, and you should uninstall it.
I don't know, but the people say the compromise package has been taken out.
They reached out to the developers, and initially there was no response, but apparently it's gone now.
So you can't update it.
But if you already have it, you should not have it anymore.
So just like a sort of PSA, public service announcement, don't use that.
Yeah.
So anything else you want to add, Brian?
No, I'm just having a great time at PyCon.
Yeah, PyCon.
PyCon is awesome.
I call this my geek holiday.
I try to refrain telling my wife that because she's like, you just got back from geek holiday.
I'm like, no, I'm really actually tired.
I need to rest.
No, you need to take the kids and do this and do that.
It's all right.
But yeah, I really love coming here, and I really look forward to meeting everybody and having these experiences.
It's exhausting.
It's exhausting in an amazing way.
Talk with nerd stuff all day long and then go out and have dinner and drinks with nerds also.
I know.
I had to have cocktails yesterday.
It was really hard.
All right.
So how about everyone in the audience, you guys want to just close it out, say goodbye from PyCon?
Goodbye.
Goodbye, PyCon.
Thank you, everyone, for listening.
Thank you for being here for this live recording.
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 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.