Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 33, recorded July 5th, 2017.
And I'm Michael Kennedy.
And I'm Brian Okken.
And we've got some pretty sweet stuff lined up for you.
But Brian, before we get into that, I just want to say this episode is brought to you by Rollbar.
They've come on to sponsor a lot of the upcoming episodes, so thank you, Rollbar.
Thank you, Rollbar, yes.
Absolutely.
You know, they would actually tell you if you had an error in your code.
But would it be better if you could actually not have errors in your production code?
It would be great to not have errors.
And so our first topic is an article titled, Linting as Lightweight Defect Detection for Python.
And it's a decent little tutorial just walking you through using how this person's workflow is using Flake 8.
And it's a pretty short discussion.
But I actually, and it has a link for, link to the PyCode style documentation.
And I wanted to bring this up because I've been trying to clean up the code examples for the book and using Flake 8 a lot.
And I was confused.
I had used it before and I was confused a little bit because something has changed.
The change is that there's a tool called Pep8 and there's a tool called Pep257.
And Pep8 checks for the Pep8 style and a few other things.
And Pep257 checks for docstring style.
But these things are now called PyCode style and PyDoc style.
I mean, the other tools still exist, but these are some new names that the community is using.
And one of the reasons why that confused me is the documentation for Flake 8 says that it uses PyCode style.
But those letters are so close together.
And I was confused because I thought it was saying it was PyDoc style and I couldn't get it to deep by default.
It doesn't care about these comments at all.
Yeah.
It doesn't check comments at all.
It's so broken.
Yeah.
And then the other thing I wanted to bring up is regarding using.
So Flake 8 is a static, a lint or a static analysis.
And highly, I think we've talked about it a little bit before.
Yeah, probably.
Highly recommended to run your code through Flake 8.
Yeah.
And what I like about this article that you put here actually is it's not just your indentation is, you know, non-standard or the number of lines is non-standard between functions or something,
but actually discovering errors as well, which is really sweet.
Yeah, definitely.
And I found problems.
There is some pickiness that I still have.
I'm kind of a curmudgeon about like having to go in and change code because there's an extra space at the end of my line.
And like, really, does that really matter that much?
But so I definitely recommend people use it.
And then also Flake 8 has plugins.
So, for instance, to do doc strings, if you install Flake 8 dash doc strings, it will check your PyDoc style as well.
Okay.
Yeah.
Yeah, yeah.
That's great.
Yeah, I like that article.
That's good.
I really do like using linters for error checking as well.
Like, hey, this variable or this parameter you're passed to a function is not used.
Maybe you intended to use it.
Yeah, things like that.
So I want to take it to another, entirely another end.
So you're down here like working on the source code.
I don't want to let you just speak like you're in Star Trek to your computer.
It'd be cool if we could do that, right?
Yeah, definitely.
Yeah.
So a friend of the show, Jacqueline Wilson, wrote, she's a teacher and she teaches, I can't remember if it's math or computer science, but she teaches people who are new to Python.
So she put together an article that's like a really friendly introduction to working with Alexa.
So this is the Amazon voice assistant thing.
And you can create these things called skills, which basically that means you can say new things to them.
So she says, let's put together one of these.
And I think the walkthrough is really simple and really straightforward.
But once you see how easy it is, if you have one of these devices available and you can do anything fun with it, you know, this should really inspire you.
Right.
So what they built or what she built in her example was a what's for dinner bot.
So you can say, hey, thing, what's for dinner?
And it'll tell you, you know, it'll pick some from things that you like and it'll tell you like randomly pick one for you basically.
So all you need are you need an Amazon developer account.
You need an AWS account and you need Python 3.
And so then you can tell it thing, you can teach it what are called utterances.
So like, what should I have for dinner?
Do you have an idea for dinner?
What's for dinner?
You could point all of those at the same functionality.
And that functionality is just a Python 3 function that lives at AWS Lambda.
Remember we talked about Lambda before and that's just like you go to AWS and you say here I would like to run, write a function.
It just takes an input and output.
And here the output is just like a JSON response that goes to Alexa.
Oh, that's cool.
Isn't that cool?
Yeah, I should try that.
Yeah, yeah.
I was actually thinking it might be fun and you could probably have it more nuanced.
Like one of my daughters is vegetarian.
So, you know, it could ask, well, is your vegetarian daughter here?
No.
Well, you should have steak.
Yes.
All right.
Well, you should have something that's not right.
So I bet you could do some really, really cool things with it.
And if you want to play around with these ideas but you don't have an Alexa, you can actually go to, there's like a website that'll let you test it.
Use your voice and just speak to the website instead.
That's really cool.
I like that.
Yeah, yeah.
It sounds really fun.
It's totally approachable.
Like basically if you can drive all the AWS console widgets, which are, there's a lot of them and it's kind of annoying.
But if you can do that and write a single function in AWS Lambda, you're like more or less ready to rock.
Oh, that's great.
I'll have to check this out.
Cool.
Yeah, yeah.
Cool.
Well, next we've got a tool called Rise, which is a reveal IPython slide extension.
And it is a slide extension or a tool for, a pip installable tool for using IPython or Jupyter notebooks to create slideshows.
And there's a couple videos out for how to do it, but the effect and the amount of work they have to put into a slideshow versus the, how nice it looks afterwards.
I think it's definitely something for people to look into if they use IPython or Jupyter a lot and need to do a slideshow for something.
Oh yeah.
Cool.
Awesome.
Great recommendation.
You know, if you're writing your research papers and presentation, written presentation already in IPython, it's kind of cool to just go, and now it's a presentation too, right?
It's great.
Yeah.
And then looking at the, I haven't had a chance to play with it too much, but it looks like there's, there's dropdowns for different slide transitions and stuff too.
So that's, that's neat.
Yeah.
Okay.
Yeah.
It looks, it looks really cool.
Thanks.
So before we get to the next one, I'm going to tell you about Rollbar.
So we talked about lending and we don't want errors in our code.
And if you run any sort of web application, web service, you guys should check out rollbar.com slash Python bytes.
Basically a couple of lines of code to integrate it with whatever your framework, a web framework is.
And it will send you notifications.
If there's any sort of error with things like full stack trays, what was the user who is running your code when that happened?
How many occurrences are there?
All sorts of stuff.
So real time notifications for errors in your sites.
I use this on my, on all my sites and I'm totally a fan.
So check it out.
Python bytes.com slash rollbar.
Wonderful.
Yep.
Good stuff.
So do you ever run processes on a remote machines, Brian?
Wouldn't it be cool if like you forget to close them down and they could just like fade away and not pile up on those remote servers?
Is that, I guess I hadn't really thought about that.
Is that an issue?
I guess.
Yeah.
Well, if you start up a bunch and they like, if basically like what if you write some Python code and it itself use basically like sub process type things to create a bunch of processes.
And if those don't properly get closed down, that can be a problem.
You know, one of them hangs or something.
The next one I would cover is called closer and closer will let you run and basically control remote processes over SSH.
So the guy who created it said it was born out of the trouble of like killing the processes that he had started remotely via SSH.
So he could start them pretty easily, but then like they would keep running and he wanted to shut them down or something like that.
So this closer, you can use this within Python and basically say like I would like the lifetime of the sub processes to be tied to the lifetime of my local Python program.
Oh, neat.
Yeah.
So the program runs and you can say cleanup.
Like when I start this process remotely, you can like get the output of that process back to your local machine.
But you can also say when this process exits, shut that down.
Right.
Automatically clean up and shut down those ones like forcibly kill them or whatever you need to do.
So it'll remotely kill all the processes either by choice or at the end of the project, the calling process.
It will capture the output.
You can do live monitoring so you can start a remote process and have it be doing a thing and basically set up a callback for like its output, a callback for when it dies.
So if it crashes before you expected somewhere along the way, things like that.
Yeah.
And the examples show that it works within Jupyter Notebooks as well.
Yeah, exactly.
So yeah, basically any process.
And if you exit that one, then it's gone.
So Closer, definitely cool.
Honestly, I don't have that much of a use for it because I don't remotely run processes over SSH.
But I can imagine like if I was doing DevOps or something, yeah, this would be a big one.
Actually, I don't often have a need for that.
And that's part of the problem is that I'm not doing it enough to where I'm really good at it.
So when I do have a need to have a couple computers working together to do or do a remote process, making sure that I get it all cleaned up correctly, that would be a good tool.
Yeah.
Well, it basically makes me think as well, like I should probably be thinking about how I could use these types of features and functionality.
I'm like, I should probably be doing that, but I'm not.
Okay, cool.
Well, speaking of things that you probably should be doing, we've actually had this recommendation from a lot of people.
And I was surprised we haven't covered it yet.
And somebody can correct me if I'm wrong, if we actually have covered it and I've forgotten.
I don't think so.
Okay, so there's a checklist for Python library APIs.
And I'd actually not taken a look at this for a while because I thought it was mostly a REST API thing.
And it isn't.
It's a topic for any, like a library API.
Oh, I see.
And it's, I'm actually not sure what the little check marks I'll talk about a little bit.
Yeah, they're actually check boxes.
I can actually check them.
Yeah, but I don't think it does anything when I check them off.
It makes me feel good when I click them.
But it talks about things like simplicity and making sure you have a readme and going through some consistency thing with naming conventions,
looking at flexibility, looking at how you're doing, what your abstractions are like, type safety,
like one of the ones to make sure that if somebody passes a wrong type into your library function,
to make sure you throw, raise a value error or something like that.
There's quite a few checklist things to go down.
And one of them, like we've talked about before, is making sure you've used PEP 8 and FLAC8.
I initially was somebody that had a whole bunch of exceptions to PEP 8 and FLAC8, but I'm doing more vanilla FLAC8 now.
It's a good checklist to look at if you are deciding to put a library up.
Maybe run through this and make sure you're doing some of the right things first.
Sure, this sort of goes along with some of your guidance on your open source package organization and some of those other types of things as well.
Nice.
All right.
I almost told you about Fades before, but I'm going to tell you about Fades now.
So Fades is not closer.
Fades is really cool.
So the problem of Python packaging actually I think is still not solved.
How do we get our Python programs to people and get them to run those things reliably?
So there's a lot of interesting takes.
There's pipinv from Kenneth Writes.
There's obviously standard pip.
There's requirements.txt.
There's a ton of different things trying to solve this problem, and Fades is one of them.
So Fades is a cross-platform thing, and what it does is basically it will auto, given any script,
it will auto-discover, with a caveat, auto-discover the dependencies of that script,
see if it has a virtual environment that has previously run,
or create a new virtual environment if it hasn't for this script,
and install all those dependencies, and then run it.
So basically you can give a script to somebody and say, run this with Fades, and run it with Python, really.
And it will handle all of the pip install this, make sure it's that kind of version,
this one has to be greater than that, and so on.
It's really cool.
Hmm.
Okay.
So, yeah, so if you're going to be passed around scripts, and they've got dependencies,
this is really an interesting way to take it on.
So I said it'll auto-discover the dependencies, but with a caveat.
So there's basically two ways to tell it what it needs to run a script.
You can use a comment.
So, like, if you said import some module, you could say, like, hash as a comment, fades equal equal three,
or fades greater than or equal to 2.1, or whatever.
And then it'll look through all the source code, find all the little fades annotations, I guess you could call them.
And then it'll create a virtual environment with those modules pip installed with the way you set it up,
and then it'll just run.
So you could ship your code with requirements.txt, but then that's a whole other level of experience
the person running your code has to have.
Yeah.
Another thing I think that's cool about it is it creates these virtual environments,
but you can basically, say, run this and upgrade your virtual environment.
So, you know, imagine, like, you just say, I'm using requests, import requests, here's, you know, hash fades, whatever.
No version number specified there.
And a new version of requests is released.
You can basically tell it, go and look for updates to the dependencies that you know about before you run it.
Oh, yeah.
Okay.
Yeah, it's pretty interesting.
And you can create these configuration files.
All right.
So basically, create a configuration file, say, my default version of Python is this,
my default update behavior is that, and so on.
And you can even clean up these old environments.
There's a way to say, like, delete all the ones that haven't been accessed for a couple of days.
Things like that.
It's pretty neat.
Yeah, it looks like it has some support for non-other repositories as well.
Yep.
Yeah, exactly.
So if you're pulling, like, out of a private Git repo or something like that to execute your code,
like for your pip install, you know, you can pass it a Git repo.
It will also, you can pass that as well as part of your dependency statement, I guess.
Cool.
In your little annotation.
Yeah.
Pretty cool.
Yeah.
Yeah, very fun.
You can even use a different index for your pip argument.
So you could come off a private PyPI server.
All right.
That's it for the news.
But I wanted to cover one quick thing.
So many people know they can add comments to the show.
Just go to pythonbytes.fm/the episode number.
So for example, this one, pythonbytes.fm/33.
And at the bottom, there's a comment section, discuss section, also powered by Python.
And last time, we got a really cool comment from Jan Oglop.
And he said, hey, Michael and Brian, I wanted to thank you for the amazing work you do and
let you know that you have helped me find the working place of my dreams.
My colleagues have similar hobbies and love Python as much as I do.
Thank you again.
That's really great.
How about that?
That's cool.
Yeah.
Congratulations, Jan.
That's fantastic.
So very, very cool.
If you guys want to leave a comment, we might read it on the show as well.
All right, Brian, anything else you want to add before we put a wrap on this week's Python
announcements?
Just that next time there's a holiday, we need to not schedule like super early recording
times right after the holiday.
Yeah, to be honest, like, you know, last night was 4th of July in the US and I was out with
my kids.
And I don't know about your neighborhood, but my neighborhood just goes off the hook.
Like there was such an insane firework display down at the local elementary school.
People just all descended and set off all sorts of stuff.
And I thought from all the yelling with my kids, I might actually not have a voice this
morning.
So yeah, and I'm acting like I'm blaming Michael on this, but I'm the one that picked the 7 a.m.
time.
So it's kind of my fault.
So it helps.
I'm still partly on Dublin time.
Well, yeah, welcome back.
So yeah, thanks.
It's good to be back.
Well, thanks again for another episode.
You bet.
Thanks, Brian.
And thank you everyone for listening.
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 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.