Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 46, recorded October 4th, 2017. I'm Michael Kennedy.
And I'm Brian Okken.
And we've got a bunch of cool stuff lined up for you, as always.
But before we get to it, we have some kind of big news, Brian.
We do.
Yes, we have a new sponsor, a brand new sponsor for Python Bytes,
who's come on to actually support a bunch of the show, DigitalOcean.
Oh, that's awesome.
Yeah, so they want to let you guys know about this thing called Spaces,
which is kind of like S3, but 10 times better.
And the audio you're listening to actually came to you over it.
So we'll talk more about that later.
I want to hear about spicy code.
Spicy? Oh.
I want to hear about SciPy lectures.
I misread that, spicy SciPy.
All the same.
Yeah, it's all the same.
You threw me off.
I'm like, what story are you looking at, man?
Anyway, SciPy lecture notes.
I saw, I hadn't come across this before, but they did an update just recently to,
it looks like they updated about once a year to make sure it's all current.
You know, for somebody that's doing just-in-time learning for scientific Python usage,
this is pretty darn cool.
Their tagline is,
one document to learn numerics, science, and data with Python.
And it runs the gamut.
It starts off with a Python language tutorial if you want to take it.
You can learn about NumPy, Matplotlib, SciPy.
It's got topics like debugging and optimizing,
image manipulation,
and things like how to deal with statistics and machine learning even.
Yeah, this is really cool.
I think a lot of people are getting into data science and getting into Python because of it.
But also, I just think this is a great way to learn a lot of these techniques, right?
These little short, focused,
IPython notebook style of examples.
Yeah, and for somebody that really needs to just jump in and find,
the way they have it set up,
it's almost like a table of contents for a book or a reference book.
So you can just jump in and try to learn whatever you need today, just right away.
You know what's cool about the JIT stuff is it has prerequisites.
It says, like, for example, on the profiling part,
it says a prerequisite is you must understand line profiler.
Oh, okay.
Yeah.
It's pretty cool.
I thought it was a great source for people that really aren't patient enough to go through a course
or really don't know what they need to learn yet.
What do you think?
That's like 95% of people.
Yeah, especially since, like we've talked about before,
that Python is often a language that people pick up after their primary language.
Yeah, well, and also I think we're increasingly asked and expected to build
more and more complicated apps, bringing together more and more different disciplines.
So would it be unreasonable to say,
I would like you to write a web application that talks to the database,
but also uses machine learning and the GPU?
Like that I can see being a totally normal request now,
whereas those used to be their own specialties, right?
So this ability to jump in and pick up a little bit on demand is only going to be more required, I think.
Yeah.
And they also split up some of the Python stuff into like some of the beginner stuff
that you just kind of have to know to start with,
and then they have some more advanced things a little bit later.
Yeah.
Nice.
So the first thing I want to talk about this week is desktop notifications.
And this caught my eye because I feel like, I've said this a couple times,
like one of the weaker points of Python is the whole desktop GUI type of thing, right?
I know you can do it, but it's just not as easy as it should be.
And so here's a real simple and easy way to build a notification,
like a desktop toast type of notification for Linux using Python.
Well, that's cool.
Yeah.
I don't know what you mean by toast.
Well, so you're sitting there and there's like a little thing that pops out and say on Mac,
it's in the top right and Windows, it's in the bottom right by the clock.
It would pop up and say, your friend just liked your thing on Twitter,
or somebody invited you to connect on LinkedIn, or your server just went down.
Your boss is paging you.
They're upset.
You know, I finally get the toast reference.
Because it pops up.
At least in Windows, it pops up.
I guess if you tilt your toaster on the right, then in macOS, it's also toast.
I don't know.
Anyway, here's an example, a little app that says,
let's write a thing that will do web scraping, I guess, a Bitcoin value location.
And it'll go to the website and pull that off and give you a periodic notification of the value of Bitcoin.
While that's not super valuable,
it does show you a really interesting use case of this package called notify2,
which if you have something actually practical and interesting you want to notify people about,
that's a pretty cool little use case.
Actually, I think I might actually use this.
This would be great.
Cool.
What would you do with it?
For instance, we've got a bunch of remote machines.
For me, I've got a bunch of VMs that are dealing with builds and whatever,
and some way to keep track of them, make sure everything's alive.
Yeah, that's cool.
Like a build, pass, build, failed, machine, no longer responsive type of notifications.
Yeah, that's awesome.
That'd be really fun.
It looks like a couple lines of code and you got it going.
So that's really cool.
Would you consider performance, like if your app becomes much slower after a check-in,
like a performance degradation, like a failed build?
Well, yeah, definitely.
And how would you test for that?
Well, funny you should ask.
The next topic is a tool called pytest Benchmark.
And this actually came up because, not because of, because I'm actually looking for this.
I need to have chunks of functionality that we need to know whether or not we need to time them,
make sure they're not getting slower with successive releases of the software.
And what's interesting is the much slower or much faster or just very random timing,
people might actually notice that.
If you're dogfooding your own application and you're using it, you might notice this.
It's the subtle things like a measurement is now, it used to be two seconds and now,
and it was for like lots of releases and now it's two and a half seconds.
Normal users might not, we're not, might not notice it right then, but it sure be good to check this.
So this is a pytest Benchmark.
And it's a very easy little thing.
You can add into your code and your pytest testing to say, hey, this chunk of code,
it needs to be at least this fast.
And at first you don't know how fast it should be.
So there's a lot of tools within it to do some graphing and table driven,
showing you what the numbers are right now.
And then also an ability to have a golden, some golden numbers and save off benchmark data into a JSON file.
And then on future runs, compare against that.
So I'm going to use it.
Yeah.
That looks super interesting, actually.
And it has nice graphs over time and things like that.
Yeah.
I mean, sometimes timing doesn't matter.
But other than like how users feel about it.
But, you know, in certain types of real time systems or trading systems, there are actual numbers.
You cannot fall below.
If you're processing inbound data in real time and it's appearing every, you know, 100 milliseconds,
you have to be lower than 100 milliseconds in the processing time, right?
Or you won't be able to keep up.
Often Python's used for other things too.
Like I've heard that some people use it to control test instruments.
Yes, that's possible.
So, for instance, checking to make sure even application turn on and measurement times don't slow down.
Because these instruments are used in production lines and it'll slow down your customer's production line if you slow down.
Yeah, absolutely.
All sorts of factory automation and all kinds of things.
Cool.
All right.
So, that's really nice.
I definitely, if I had a use case for that, I would definitely use it.
I just don't have anything that I can say it must be this fast or it's a problem.
But it still would be cool to actually see the speed over time.
Now, before we get on to the next one, let me say thanks to DigitalOcean and just let you guys know about Spaces.
So, you probably heard of Amazon S3, right?
I think that was their first thing.
But, like I said, DigitalOcean just released Spaces and I definitely think it's better.
Soon as I heard about it, before they even said, hey, I want to sponsor the show and have you tell the world about it, I'm like, I'm switching to this thing.
So, for one, it's like nine times cheaper than AWS.
It's super predictable pricing.
There's all kinds of benefits.
You can use the same tools as you used to manage your S3 thing.
So, same APIs and everything.
So, for example, I use this cool program called Transmit for my Mac to manage all my files in S3.
Just point it at DigitalOcean Spaces and it just keeps working.
It's awesome.
So, it's like $5 a month, 250 gigs for free in storage, a terabyte for free in bandwidth.
That is quite expensive if you pay $0.09 per gigabyte at AWS.
But it's completely free here and it's a really nice service just as fast but much more predictable.
And even inbound data is 100% free.
So, check them out.
It's really a super simple API.
It's one you're familiar with, the tools of work.
And you can actually get, whether you're a new or existing customer, you get two months free if you just go to do.co slash Python.
So, check it out.
That's great.
Cool.
Yeah, it's a super cool project.
I'm so happy they came out with it and I'm happy to be using it for this podcast and other stuff.
So, we've talked, you've talked more than I have, but we've both talked a fair amount about projects, how they do packaging, Python packaging, how you should structure those and so on.
So, I want to highlight an article that is, it's a fun article, but it's super in-depth and a deep look inside of how Python works and how packages are built and why they're built that way.
It's an article by Vicky Boykus and it's called Alice in Python Project Land.
So, it's got some cool little graphics and stuff, but the idea is like, she's a data scientist learning data science and those things.
So, doing a lot of Java and doing a lot of Python.
It's like, look, Python is so much better except for it's really hard to package up things.
Like, how do I take some code that I've written and make it so that I could give it to you and you could use it, for example.
So, instead of just going, well, these are the four steps you do to create a Python package, she says, let's look at the internals of how Python actually works.
She said, how it runs, how it understands and links things together.
And so, you not just know how to put things together, but you understand why.
So, very, very interesting article.
Pretty in-depth.
So, packaging has always been kind of this weird thing that you just follow the steps.
You can check this out.
It's a good article.
Like you said, it's in-depth, which makes it kind of a long article, but the writing is really good.
So, it moves along pretty fast.
Yeah, it sure does.
It sure does.
And it answers a lot of questions like, should you use setup tools?
Should you use pip?
What does dunder init.py do?
Should I mess with Python path?
Should I not?
And another thing that I saw that she referenced in there was pretty cool.
It's called piprex.
Have you seen this?
No.
Yeah.
So, I think piprex, you pointed at your code and it looks at all your imports and it then knows what to create for your requirements.txt.
Cool.
So, instead of remembering like, oh yeah, there was that thing that I used, Colorama or whatever, and I forgot to put it in the requirements file, so it's not going to work.
Like, this will just discover it.
It's really cool.
So, yep.
If you want to get like an understanding of how Python packaging and assembly of modules at runtime works, definitely check out this article.
It's super approachable, but well done.
Next article, how to teach technical concepts with cartoons.
Love technology.
So, I personally, since I came from computer science, from the art, fine arts actually, I started out in fine arts, and I actually gave up because I was frustrated with my ability to draw.
But drawing things to help people understand concepts, it's very, it helps.
It's easier to understand things, and nobody expects you to draw really great pictures.
This article starts off, I love this, it starts off with just saying that she draws not that great.
It has really three horrible pictures of a dog, a cat, and an elephant.
I don't think I can do better, but they're not great drawings.
But just then going through and talking about how people should use drawings more when trying to teach things, and some tips on making them more personable.
I think it's a really cool idea.
You certainly can personalize and humanize technical concepts if you use pictures.
Like you said, they don't have to be super fancy, so she has a dog, a cat, and an elephant, and those sorts of things.
But you know, not far down, she says, oh, let's do something about a mutex.
And actually represents how mutexes are used to like, for shared memory, or something like that, right?
And it's completely approachable, but somehow it just makes it much more, if you looked at the formal definition of a mutex, like, oh my gosh, what is that thing?
But here it's like, oh, okay, well, that's totally simple.
I think you can really convey a lot and sort of disarm people with some nice drawings.
One of the things I like about this article as well is it itself is a mix of hand lettering, just her normal printing, and some simple drawings with text.
That's what the tutorial is.
And it breaks it up a lot.
And I think a lot of technical people, when they're trying to teach something, they'll think a drawing is a good idea, but then they'll get out a tool to make all the lines straight and draw it with vector graphics.
And sometimes I think just a pen and paper might help convey the information better.
Yeah, yeah, absolutely.
I think this is really cool and hopefully inspire some people to do a little more freehand stuff.
It doesn't always have to be perfect.
So keeping it graphical for our last item, I want to share the Halo with you.
So Halo is a project called Beautiful Terminal Spinners in Python, which is what it sounds like.
It's a really simple library that will give you sort of I'm loading or I'm working or I'm thinking type of spinners and a lot of cool features.
So you can have the little spinner go around and you have different styles.
You have successful outcomes, failed outcomes.
So like this little spinner will spin and then it'll go to like a check mark if it succeeds.
Or if it fails, it'll go to like a cross and you could make it red or something like this, right?
So that's really cool.
We talked about progress bars where you have the progress going across.
You know, I think one of the better ones is TQDM.
Sometimes you don't know what the progress is going to be, right?
Like I hate progress bars that go it's 5%, it's 5%.
It's 90%, 91% and then it goes forever and then finally it's done, right?
There's a great XKCD.
I'll put it in the show notes.
It's really fun about the guy who built the Windows progress bar, file copy progress bar.
But sometimes progress bars aren't the answers.
There are reasons why I'm bringing it up.
But little spinners sort of solve that problem because it doesn't indicate progress.
It's just like we're busy.
And so here's a really cool way to put that into your program.
It's very simple and it really looks nice too.
Yeah, definitely.
And it has a unicorn, a colorful unicorn.
He doesn't want that.
I'm not sure how the unicorn displays progress though.
No, maybe in the horn.
Oh, that would be cool if the horn had like colored.
Yes, like the horn like flashed like rainbow.
Yeah.
I don't know if it does that or not, but it should.
All right.
But if you're looking to add some sort of user feedback like, hey, we're busy.
We're not locked up.
You know, Halo, super easy.
Very cool.
All right.
That's it, Brian, for our topics.
You got anything else?
I don't think they would have made a full story, but I wanted to let people know that the Python,
I think it's 363, is out now.
So go upgrade.
I don't know if there's anything major in it.
I haven't looked through it, but it's around.
So keeping current is good.
And then there's also a bug fix release I noticed in pytest.
That's around.
I'm not sure what's in it, but again, it's around so people can pay attention.
Yep.
Okay.
Very cool.
So check those out.
And the last thing I wanted to mention is I haven't been, I warned people that I was going
to start podcasting again, but it took me a while.
You warned them.
Look out.
I'm going to do it.
Yeah.
There are a couple.
So at the end of September and just a couple of days ago, I released a couple different test
and code episodes.
One of them related to the testing pyramid.
And the last one, 32, is an excellent one by an amazing speaker.
It's with an amazing speaker named David Hussman.
And he's a brilliant man.
Yeah.
That's really cool.
And I'm glad you got that one out.
That's awesome.
How about you?
Anything new going on?
No, nothing new.
I'm working on my courses like crazy, but the announcement's going to have to wait until
next week for anything to be actually out for anyone to check out.
Well, thanks a lot for doing this today.
You bet.
It was great to catch up with you and share all these ideas with everyone.
Catch you later.
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.