Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 66, recorded February 22, 2018.
I'm Michael Kennedy.
And I'm Brian Okken.
And we have a ton of stuff.
As usual, we've scoured the web.
And actually, I don't know about you, Brian, but I had a really hard time actually picking the topics.
Every one I found was better than the last one.
It's exciting to see a lot of content out there.
Yeah, for sure.
So I want to say real quick, thanks to Rollbar.
Check out what they're doing at pythonbytes.fm/rollbar.
Add error reporting and real-time monitoring to your web apps and other things.
We'll talk more about them later.
Right now, let's focus on modern Python a little bit.
I wanted to bring up, there's a lot of tutorials on how to do object-oriented programming and also object-oriented programming in Python.
But real Python put out an object-oriented programming in Python 3, which I think is just a nice update.
Just making sure that everybody understands currently how to do things.
If you want to do classes and objects and inheritance.
And to be clear, all of Python is object-oriented.
It's just everything's an object.
I hope that's true.
Pretty sure that's true, yeah.
Even functions and numbers and all that stuff.
What this is meaning is if you're going to define your own classes, how to go about doing that.
And this is a pretty nice tutorial.
One of the reasons why I wanted to call it out is there's a reason I'll get to later, but he kind of didn't.
He brushed by construction.
So if you came from C++, one of the things that C++ does is it calls your base class constructors automatically.
And I wanted to just call that out.
Right.
Especially if they're parameterless, right?
Like, it'll just happen straight on the stack, right?
Yeah.
You don't have to be explicit.
Yeah.
But in Python, you do have to be explicit.
If you override init, the base class init will not get called unless you call it yourself.
And there's been many incantations of it, and I think the recommendation right now is to just call super.init to call the base class constructor.
Yeah, yeah.
Definitely.
Very, very cool.
Worth checking out.
It really digs into the object model and inheritance and all that kind of stuff.
So if that's a little bit shaky to you, definitely check it out.
Even has some little exercises and examples in there, right?
I guess also if you're not a bad thing to brush up on if you're just about to go into an interview, probably.
It's a nice article.
Also, pay attention.
I've been playing with adders a lot if I need objects.
So make sure that it's a really easy thing to pick up if you want to check that out as well.
Yeah, that's cool.
Adders is pretty sweet.
Definitely a lot of really solid people make it a great recommendation.
So it appears frequently at the end as the featured PyPI package on Talk Python, for example.
Yeah.
So you want to stay on a GUI trip for a while?
How about we keep going?
We really opened a bag, man.
When I started that, it really kicked off a, oh, but Michael, did you hear about this?
Did you hear about that?
And I'm happy I did.
And I love all the things people are sending us.
Learned about WXPython Phoenix, which I only knew about the older version, which is really awesome.
I learned about GUI, G-O-O-E-Y, and WUI, and all these other interesting things.
So I come to you, Brian, this week with yet another thing called scripted forms.
So tell me, how's your Markdown?
I love Markdown.
I use it all the time.
Yeah, Markdown's not hard.
Yeah, it's not bad, right?
So here is a project in Python that lets you basically sketch out a UI in Markdown.
Then it becomes an interactive GUI with input fields and everything.
Okay.
Neat.
I got to check that out.
Yeah.
So for example, like you want the title, like a big title at the top of your form or your window, hash space type out the title.
Isn't that cool?
Yeah.
So you can do all sorts of interesting things in there.
It's not like a lot of these are not totally general purpose.
But if you want a simple UI, check out this thing called scripted forms.
Of course, we're linking to it in there.
And you just basically sketch it out.
And it runs actually on Jupyter.
But the way it gets packaged up is you just see like a desktop window pop up and then it's interactive.
So it's pretty cool.
They got some examples and all kinds of stuff.
You can have like sliders and live graphs.
And so this looks particularly interesting to data science-y folks who have that kind of display stuff going on.
That's cool.
Yeah, it's cool, right?
So scripted forms, there's yet one more way in which you can create niche Python GUI apps and then bundle it up with something like PyInstaller.
I definitely want to try that.
Yeah, yeah, I do as well.
So do you know that I'm a fan of MongoDB?
Yeah, you're like the Uber fan.
I am the Uber fan.
I love it.
I talk about it, do stuff with it all the time.
Like, for example, Python Bytes, the web app, is driven by MongoDB, for example.
But you actually, you are the one to bring the big news, not me, on MongoDB these days, right?
I guess so.
I was surprised, but I grabbed it.
The news that came out on the 15th was that MongoDB will, and it doesn't do it right now,
but in the 4.0 release, it will do multi-document transactions and have ACID data guarantee integrity guarantees.
That's kind of blown my mind.
One of the big things that Mongo has done is really focused on going to treat the document level record as the thing.
That way we can do sharding and auto scale out and all kinds of stuff and not worry about communicating across machines and clusters and all the other pitfalls you can run into by trying to do really complex transactions.
So this, you're right.
I didn't see this coming either.
So this is due out in the summer.
So the 4.0 is supposed to do transactions.
And the 4.2, which is the, I'm not sure when that's coming out, that will even deal with transactions across sharded deployments.
Wow.
That's really cool.
And it has snapshot isolation.
So even the sort of repeatable read type stuff.
Very cool.
So yeah, they said sometime this summer, right?
The ability to do transactions and hopefully you will get things like rollback and things like that.
These are a lot of the reasons why people don't choose a document database.
And so that changes the table of pros and cons.
It definitely changes the tradeoffs that you're considering.
I just find working with these document databases so much easier.
Like the last time I ran a migration or worried about upgrading my database schema to match a new deployment was never.
Like I literally have not had to run any form of update script for the last two years on training.python.fm, on Python bytes, or any of these things, right?
Like they just adapt.
And it just makes the sort of living with it so much easier.
So I'm really happy to see it get one more check in the sort of comparison table in that column.
Yeah, definitely.
Yeah, very cool.
So if I did mess up my schema and something went wrong, though, my web app would crash.
That would be bad.
And actually, working with Mongo Engine, you can like basically take the site down because it will like not read records if it thinks it's inconsistent with them.
So that's a different type of problem.
Same thing happens with SQLAlchemy.
But if I did that and I had Rollbar installed like I do, we would know about it right away.
We'd get little notifications in Slack and email and pop-ups and stuff saying, hey, the site is down.
Something has gone terribly wrong.
Like just the other day, I was sitting around and I started getting all these notifications of something going wrong with the site.
I'm like, oh, what is this?
Why are these, you know, like on Python bytes and Talk Python and whatnot?
And I pull up Rollbar and it says cannot find MongoDB server.
How about that?
And the reason is the digital version of the host was actually patching the underlying Linux servers for the Spectre and Meltdown vulnerabilities.
So they had to take the machines down.
And they didn't do it in like a controlled way because they're just like, we're telling you at some time we're taking the machines down.
We've got to fix this.
So even when it's not your fault, you'll know about it if you have this installed and you can at least switch, you know, switch up a dialogue or a page saying, oh, sites are super maintenance right now.
Sorry.
Yeah.
That's cool.
Yeah.
So super easy to install it.
Not much work at all.
Plugs into all the web frameworks.
Check it out at pythonbytes.fm/rollbar.
So another kick that you've been on for a while, Brian, is Python packaging.
Yes.
We talked a lot about what the right structure that is and all those various things.
So this week I want to feature this thing called Python packaging pitfalls.
It's not super new, but I thought it might be fun to cover anyway because we've talked a lot about it and we haven't covered this.
So a couple of items that I don't know how many there are, probably 10, 12 little things.
Don't forget to do this.
Don't forget to do that.
Like don't forget, you know, so if you're doing packaging, you might forget to clean the build directory before you do it.
Or you forget to specify package data or using package underscore data or fine grained package data.
All sorts of mistakes that are listed there.
And it says why it's really nice.
The article says, why is this a problem?
How do you fix it?
Like hard coding your packages in the setup py versus like discovering the packages with Python code in your setup py.
Yeah.
These are all great tips.
I haven't read this for a while.
I remember reading it a couple of years ago to try to make sure that most of these look like they're still valid.
Yeah, I think so.
One of them that might be nice and close for you is your test the installed code.
They test what's actually in your working directory rather than running the setup and testing the thing that actually was the result of that.
Is that one of the things to avoid?
That's one of the last things to say.
Be careful of make sure you test the actual install result, not just your code on development.
Yeah.
And that's one of the reasons why I really like Tox is because Tox creates like these clean environments.
But you still have to be careful of that even with Tox.
That's why we talked about using a source directory.
Absolutely.
So a while ago, I had a bunch of authors, including you on Talk Python, about writing.
And some people were asking, like, how do you become a better writer?
And you said, by writing.
Right?
Just get out there, blog, write, do things like that.
So you came across something like that again this week, right?
Yeah.
I came across an article called Blogging Principles I Use by Julia Evans, which I think it's cool.
She goes by Bork on Twitter with a zero.
But I'm just going to read through her tips and then we can talk about them.
Be honest about what you know.
Try not to write anything too long.
Be positive.
Write for the past you.
Stick with your own experience.
And it's okay if not everyone likes it.
And a lot of these really hit home with me.
One of the things, try not to write anything too long.
I tend to try to, like, completely get my head around something and not want to write about it until I completely understand it.
And then sometimes I don't have time to do that.
And I think that's too bad.
And I think I love it when people just have little couple screens full of information of just,
Hey, I learned this neat new thing.
Here's how to do it.
And just go and teach it so other people can learn from you.
It doesn't have to be huge.
So be okay with short things.
If you do short things frequently, that's probably better than saving up that one long post that actually never gets written, right?
Yeah.
Also, one of the things you can do is with metrics as well.
If you, instead of writing a long blog post that has, like, five subtopics, write five different posts.
And then you can find out which piece of this resonating or easier metrics, we'll just point it out.
Yeah, that's a really good point.
The last one is, it's okay if not everyone likes it.
And her example actually is, she's got a, I forget which article it was, but one of her articles is more popular than others.
And she needs to remind herself to not try to try to keep up with that.
It would be a mistake to try to hit that every time.
That's actually something that hits with me is I, I haven't been blogging a lot lately.
I do want to pick it up.
I think I need to, it will help me to try to write shorter stuff.
And also, I've got a few tutorials out there that are, that are really popular.
And I don't know how to beat that.
So, don't try.
Just write little things.
Like, I learned a few new things during the webinar today.
I learned some new things about PyCharm.
And I could just, like, write a couple, a short blog post about cool things I learned about PyCharm today.
Yeah, that's awesome.
Why not?
Yeah, why not?
And definitely, I feel like these little series ones are real nice.
Like, I've done several, like, here's, I'm going to write, I'm going to blog 10 blog posts in this kind of theme.
And those turn out to be really easy to write.
But I also find that I periodically get distracted and just life gets in the way and I don't finish them.
I'm like, here's the top 10.
And, like, they have seven filled out, you know?
Yeah.
So, I mean, I think that's a really great way to do it.
But maybe actually write the 10 and then do the, hey, I'm doing a series on it.
You know what I mean?
Like, kind of do it in reverse a little bit to bring it together, what you've done.
I think that one of the takeaways I would add is, like, it is so hard to predict what is going to be popular and what is not going to be popular.
It's just, you know, you look at things and you think, oh, this is going to be so popular.
And it gets, like, 100 views.
Like, you're like, I guess I'll throw this out.
Why not?
I got a half hour and it's kind of on my mind.
And maybe it won't matter.
Like, it's thousands or hundreds of thousands of views.
It's just like, okay, why is that like this?
Right.
So, just put stuff out there and it will happen.
I think the write for the past you, I fall into this trap of trying to write for, either write for experts and try to impress the people that know more than I do, which that's a bad place to try to be.
And trying to write for absolute beginners.
But I haven't been an absolute beginner for a long time.
So, I don't really know how to do that.
So, I think writing for, like, me a month ago.
If I would have read this article a month ago, it would have saved me time.
So, just write it down.
Yeah, yeah.
Absolutely.
Very cool.
So, we spoke about pipenv, P-I-P-E-N-V, a while ago.
But I want to bring up something that I just, I don't know why I found this.
I just randomly ran across this.
So, I was looking at pipenv again for something.
And so, pipenv is a way to kind of package up virtual environment, dependencies, requirements.txt, pip, activating the virtual environments, all that kind of stuff into, like, one little workflow.
Okay.
Now, Kenneth writes is behind this in a significant way.
But I somehow was looking across it.
And I saw that it's on github.com/pypa, the Python Packaging Authority, slash pipenv.
Hmm, interesting.
And then I scroll down and it says pipenv, the officially recommended Python packaging tool from python.org.
Free as in freedom.
Did you know this is the official way, like, pip and requirements.txt is apparently out?
No.
I didn't either.
That was my reaction.
Like, wait, what?
I mean, I know there's pipfile and pipfile.lock and all that kind of stuff.
But it seems to me, reading this at least, that, because this comes from PyPA, that pipenv is the way we should be doing things.
So I don't know about you, but I need to study this and kind of get in touch with it.
Because I feel a little bit lost when I use pipenv.
And I'm really confident with pip and requirements.txt and all the stuff I do there.
I guess I'm comfortable with pip and setup files.
So I will have to read up on this, too.
So do you know if you can just get away with doing this and then pushing a package up to IPI?
I don't know, but one of the things you can do is you can tell it to generate a requirements.txt from its behaviors and its lock files and stuff.
Okay.
So let me give you the quick workflow.
If you go there, there's a docs.pipinf.org, which you can go to.
And it has a nice little screencast from Kenneth Wrights.
It's like four minutes.
It says, let me show you this new tool.
I've been working on it with a bunch of people, and it seems really nice.
Here's how it goes.
And so you just go into a directory, no virtual environment, nothing set up.
And you say pipenv install a thing.
And if it's never run, it will create right there.
What is it?
A pip lock file.
A pip file and a pip.pipfile.lock.
And it will somewhere in like your temp working area create, not in that folder, somewhere else, create a virtual environment and install it into that.
If you type pip install, a pipenv install another thing, it'll put it into that same environment because it now is like tied to the pip file.
And it'll actually automatically add the requirement to your pip file and to your pip lock.
And the pip file is like requirements.txt.
The pip file.lock is like that plus the dependencies.
So it's like pip freeze everything, not just what you pip installed.
So it's pretty cool.
And then you could just pip shell, pip inf shell to kick it off.
Or you can find the, there's a command for finding the virtual environment.
So then you can, you know, source activate it just tradition, like traditionally.
Okay.
And actually the video is like the reason why I gave it a shot because just reading about it confused me, even though I read it like seven times.
I know.
Like, why is this bouncing off me?
But then you watch him use it in like this little couple minute video and it's like, oh, okay, that's easy.
Yes, exactly.
Another thing I like about it is it says Windows is a first class citizen in our world.
Wow.
That's rare.
That is.
It's really nice.
Like I have a Windows 10 setup, but I typically work on my Mac.
But I know many, many people in the world use Windows, especially in like large enterprise environments.
And having Windows be a first class citizen in the Python space is good for everyone.
Yes.
Well, this is neat.
Yeah.
So just like really the news for me is like it's a review of pip inf, but the fact that it seems to be the officially recommended way over the traditional ways we've been doing it means I need to pay more attention.
Yes.
Very cool.
All right.
So that's our set of items for the week.
You just did a webcast, right?
Which you will probably have live certainly by the time this goes.
Well, probably by the time this goes out.
Well, it was already live.
It was live this morning.
Well, I mean, the recording will be out and available.
Recording should be out.
Yeah.
That was with the JetBrains PyCharm team.
And that was super fun.
I had a good time.
We talked about using pytest within PyCharm.
And we just scratched the surface.
There's a lot more to cover.
But it was fun.
Sounds really cool.
Awesome.
So we'll definitely link to the video next time, I'm sure, because we'll know where it is.
Also, I have two quick follow-up items.
One is the Pandas.
The whole Pandas project is super important in data science.
Gosh, I'm sorry.
I forget the guy's name who sent it to me.
I got a message saying, hey, we're having this really interesting idea of the Pandas documentation sprint.
And these are throughout the world.
And to say how many locations, I don't know.
Quick counting.
Let's say 15 locations throughout the world, slightly biased towards Europe, but also everywhere, but apparently Australia or Antarctica.
There's these physical locations like San Diego, Seattle, and so on, where people are getting together to do sprints on the documentation for Pandas.
That happens on March 10th, 2018.
So a couple weeks.
Yeah, and it has a countdown all the way down to the seconds.
Definitely has a, yeah, down to the seconds.
We start now.
I think this is a cool idea.
If you've never contributed to open source and you want to get that check mark on your resume and you want that on a major project,
here's a really cool way to become a contributor to Pandas without deeply understanding it or having majorly adding a feature.
And also, you get to hang out with people who are experts in Pandas.
And so those are probably good connections to make.
So check that out at python-sprints.github.io slash pandas.
That should be fun.
Yeah, and every open source project will love you if you write documentation for it.
Yes, absolutely.
Okay, so really great.
And then the other item I wanted to follow up with is we talked about the workflow in Unreal coming from, was that Autodesk, I think?
Anyway, really, really cool stuff that they were doing there.
And now someone followed up and said, that's really great.
Do you know you can now embed Python in the Unreal Engine 4?
Wow.
There's this project called Unreal Engine Python, and it lets you just embed there.
So it's like a plug-in for embedding the entire Python VM 3 or 2 in there.
And then, you know, you can basically add scripting into your game and let people write Python and control your 3D environment.
Pretty cool.
So just a quick follow-up from when we talked about that before.
Thank you for being here.
It's great to chat with you, and I love your picks this week.
Thank you.
You too.
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.