- Podcasts
- Python Bytes
- #57 Our take on Excel and Python
About this episodeTopics covered in this episode: Testing Python 3 and 2 simultaneously with retox Robo 3T / RoboMongo regular expressions MongoEngine…
- Testing Python 3 and 2 simultaneously with retox
- Robo 3T / RoboMongo
- regular expressions
- MongoEngine
- Introducing PrettyPrinter for Python
- Excel and Python
- Extras
- Joke
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#57 Our take on Excel and Python
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 57, recorded December 19th, 2017. I'm Michael Kennedy. And I'm Brian Okken. And we have a bunch of really cool stuff to share with you. As always, we've been looking through all of the news sources and finding all the Python goodies for you.
What Tox does is a tool that will run your setup if you have packages. And you can turn that off if you don't want the setup to get tested. But it'll test your setup and then run it in different environments. And the typical example is running multiple Python versions. Running all your tests in multiple Python or multiple library versions to make sure all your tests pass.
And there is a Detox version that can distribute that across processors. Can speed it up two to three times or two to four times faster or more if you run it on distributed processors. Or if you spent like, what, $15,000 on a new iMac Pro and got 18 cores? Yeah, yeah. You could be 18 times faster or 16 or something.
Anthony put together Retox, which does all this, but also does it with a nice GUI so you can watch your tests run, which is really kind of cool. And he did it for Python 2 at first and then very quickly within a week, ported it to Python 3 with some problems along the way. But he worked through them, which is nice.
Yeah, well done. It also has the cool capability of watching a directory. So you can have this GUI sitting up on a monitor somewhere if you've got a couple monitors or in the corner of your window. And then it'll watch, you can have it watch your source code and when you, as you, as you save changes, it tests everything on multiple versions of Python or multiple hardware or whatever you want to do.
Yeah, that's really, really cool. Very cool. You know, I'll just describe kind of what it looks like. So you run it in terminal or command prompt and you get like an ANSI art type of interactive thing. And it shows you different columns for the different tests that are all running like Python 2.7, Python 3.6, Lint, PyLint, all these things running in parallel and their status.
It's pretty cool, right? Yeah. And one of the things I was trying to do this morning, getting a chance to quite get it done with meetings and all. But instead of running Python 2 versus 3 and stuff, what I'm going to use it for is running the same set of tests with the same Python, but against different instruments.
So I can run across multiple hardware. That's cool. So you're parallelizing the same code running, but against, you're parallelizing the hardware, not the versions of Python. Yeah. Yeah, that's pretty awesome. That'll be good. Yeah, that'll be good. So I thought this episode, I'd talk about some of the tools that I've been using for a little while that I really enjoy, but just haven't thought to bring up on the show.
Anyway, what this thing is, is a shell for MongoDB that you type. So a command line type of interaction with it, but all the results appear as a GUI result. So you have this kind of part where you type in and you run commands against Mongo, but all the results show up in maybe a tree view, or you can right click and interact with them once the results come back and stuff.
It's still the straight interface for working with it. But all the results that come out of that interaction are GUI based, which I think is cool. It's also interesting in an open source way. On one hand, it's number 34 most popular repository on GitHub, which is cool. It's built with QT, which makes it look like a really nice cross-platform app, which you could build out with PySide or PyQt, I think, and get the same looking app.
Yeah, definitely. But there's definitely some times where I've been using regular expressions for as long as I've been programming, almost. So programming's always been hard. Yeah. Yeah. Yeah. Shortly into my CS program, I got thrown a Perl book and said, learn this. So yeah. Anyway, there's a couple articles that came out recently that I thought were really good for people that need to get a handle on regular expressions quickly.
So it's good to sort of learn some of the regular expressions with that. Yeah. I really like the example driven approach as well. Like, here's how you match a bunch of different things you might want to. And also the fact that it's using the Python libraries and not just here's a random regular expression means it's really quick to just drop in directly, which is cool.
And then there's another article called Regular Expressions for Data Scientists that do some of this. But then also it's mostly focused around parsing text, of course, with regular expressions. But it's also a good intro and it dives a little bit deeper into find all and search. And so I think check both those out if you want to beef up on regular expressions.
Yeah, that's really cool. Nice. I like the motivational introduction for the data science one. Sometimes, you know, this might include searching massive corpus of text. For example, suppose you're asked to figure out who's been emailing whom in a scandal of the Panama Papers. That's 11.5 million documents.
We need regular expressions. Let's go. Yeah, definitely. Yeah, very exciting. Very exciting. Cool. So before we go on, let me just tell you about the sponsor for this week's episode. That is DigitalOcean. Thank you, DigitalOcean, for sponsoring the show as they are, I would say, the major sponsor for the show.
They definitely sponsor it more than anyone else. And with good reason, they have really, really cool things going on over there. You know, there's a lot of places you can get your cloud computing resources, but a lot of them are overly complicated, overly expensive, and so on. With DigitalOcean, go over there, quickly set up a server, set up some storage, link them together.
It's really wonderful. So this site's website's running on DigitalOcean, among a bunch of other things that I'm running as well. So definitely a great place to check out. And you can get started by going to pythonbytes.fm/DigitalOcean. So keeping with my theme of things that I want to talk about that I've been using and really enjoying but haven't bothered to bring up on the show, to complement the other side of the story with the MongoDB thing is MongoEngine.
So you've heard of SQLAlchemy, right, Brian? Yeah, definitely. Yeah, so that's probably the most popular way in Python to talk to relational databases. Well, the MongoDB equivalent of SQLAlchemy is this thing called MongoEngine. There's a handful of these so-called document, object document mappers, because you don't have a relational.
So it's not an ORM, it's an ODM. And anyway, there's a handful of these for MongoDB, but this one really is quite needed. Let's you take a class, derive from a base class, and map it into MongoDB. And the way you work with it is very similar to Django's ORM, actually. You map a class, you create an instance of it, you call save, you can do queries on it, all sorts of stuff.
But leveraging the hierarchical document TV nature of MongoDB, it also adds new features. Like, MongoDB doesn't really have schemas in general, like, they're starting to add some of these features. But there's no schema definition, it's just whatever you put in there. With MongoEngine, you have a schema that matches your classes, so you have some reliable data structure.
MongoDB has no concept of required fields or constraints, like this number must be between 10 and 1,000. But MongoEngine does, relationships, all sorts of cool stuff. So it really provides a lot of nice structure around working with a NoSQL schema-less database. Oh, that's nice. Yeah, definitely check that out.
Yeah, so I've found this to be super helpful. Like, actually, a lot of my sites are implemented, including Python Bytes, for example. The one thing that's a little bit of a pain is the deserialization speed is not awesome. So if you retrieve 100,000 records from MongoDB, that's really fast, probably.
But somebody was taking a look at all the different ways to Pretty Printer their output for debugging your code. And it wasn't really happy with them. So added yet another. But this is kind of extensible and cool. So you can add on, if you have a particular way you want to print your classes or your calls to different functions, you can customize that.
So it's very nice and has a nice declarative API as well. So you can even extend it, right? There's an example in there to be able to extend your call with comments even. So let me ask you a question. What do you think the most popular database in the world is? MySQL. MySQL is definitely a good one.
You've got formulas and whatnot. So Excel is really super important in the business world all over the place. Well, it so happens that Microsoft is considering replacing the macro scripting language for Excel that is built into it, VBA, with Python. Yes. That would be very nice. So on one hand, I'm like, whee, I don't really want to program Excel, right?
It doesn't make me super excited or super happy. On the other, look at what the adoption of Python in the data science space has done for Python in general. It's really, really complemented it and made it a better place. I think that's what would happen if Python became the main scripting language of Excel as well.
There's all these people who are not really working in this space now. All of a sudden, they'd be super interested and contributing things that who knows what they would actually come up with. I'm imagining this is actually pretty cool. I'm imagining a manager working with a spreadsheet and wanting to add some macro capabilities and getting a little bit too deep into it and getting a little lost, grabbing a developer and saying, hey, can you help me with this?
And right now, if it was me, I'd say, no, you're on your own. I don't want to do that. I would hide under a desk like, no, Michael's busy. Michael can't talk right now. He's looking for someone to work on PVA. Stay away. But if it's a Python interface there, yeah, I'd help out. So I think the interaction between developers and managers would increase dramatically if Python was in Excel.
Yeah, I think it would be super cool. Who knows what the chances of this actually happening are. I tried to get Python into Windows because, you know, it doesn't ship with Windows. So Microsoft has this place called User Voice where you can like, but maybe it's not even a Microsoft thing, but they use User Voice, which lets you vote on features and requests and things like that.
So I actually got over a thousand people to vote for shipping Python 3 with Windows 10 before it actually came out, but no dice. However, they did put Python into SQL Server so you can do in-process machine learning against your data. So there's one example of them doing this, and if they'll do it for SQL Server, they may well do it for Excel, which would be awesome.
So everyone listening can have a voice on this. If you go there, click the link, upvote the item, and there's a survey you can fill out and tell them, Python 3, please, we'll take more of that. That'd be awesome. Yeah. So if this sounds cool to you, be sure to go there, at least upvote it so that they know this is something we all want.
So we have a tree up now, but we haven't decorated it. So that's our decorating for Christmas. That's awesome. That'll be a fun, fun thing. Kids going to be home from school pretty soon? They're all home now. So that's fun. So work is super productive these days. Yeah, I can actually get to work at a decent time.
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.
