developer chats

Getting into Python

Episode Summary

Will Button and Miller Hooks, two experienced Python developers, have a conversation about the differences between Python and Javascript, and what that means to a new programmer.

Episode Notes

Will Button and Miller Hooks, two experienced Python developers, have a conversation about the differences between Python and Javascript, and what that means to a new programmer.

Python is downright awesome for a beginner, due to it being more readable and there not being a mountain of frameworks that all seem like completely separate languages. Not only that but there are amazing tools that enable a beginner to just jump right in and create.

Python is learnable to the point that even people outside of software development are using it as a tool to automate annoying manual tasks. Scripting away all the hard repetitive tasks at work until everyone thinks they are some kind of wizard.

One of the tools mentioned in the podcast is the wonderful Cookiecutter Django. A great tool for beginners who don't want to deal with a million installs and an array of different skills just to get a project deployed.

The other tool mentioned, The Jupyter Notebook, gets python up and running right in your browser. Inline code and rich text documentation allow you to write code and see the results inline, even giving you the power to write documentation around the output.

Check out Will's new egghead course, Intro to Python, and jump into this rich, beginner-friendly world.


"Getting into Python" Transcript


Miller Hooks

Will Button

John Lindquist

Episode Transcription

John Lindquist: Welcome to an podcast on Python for JavaScript Developers, featuring Will and Miller. Alright let's go ahead and get started by introducing ourselves. We got Will and Miller. Will if you wanna go ahead and go first; name, experience with the Python, all that sort of fun stuff.

Will Button: Yeah. My name's Will Button. I work with tech startups on scaling automation and currently working with Active. I've been working with Python for a few years now and have used it in all sorts of interesting applications as background scripting engine for servers, for a deployment process, lots of ETL tasks and some websites, and even done some cool stuff with it in AWS Lambda.

John Lindquist: That's a wide variety of stuff. Miller, go ahead.

Miller Hooks: Yeah. I'm Miller Hooks. I am a software developer. I've been doing it for 15 years. About 10 of that's with Python. A lot of GIS mobile development, RESTful interfaces. In the last few years, more machine learning, SciPy, NumPy and I'm an engineering manager over at Graphistry where we have a really great Python library for doing interesting visualizations.

John Lindquist: Awesome, I'll have to check that out. Our audience is mainly JavaScript, egghead has been JavaScript in the past, and we're branching out into other things. Let's just go ahead and do some Python, JavaScript comparisons. What do you guys love about Python and what do you think JavaScript could learn from what Python does well? Kind of big broad question.

Will Button: I think for me, the big difference that stood out for me, in going from JavaScript to Python was just the asynchronous behavior. Async has a definite place in JavaScript's origin of the browser but then whenever I try to use it for things like ETL processes, or things that had to go very sequential in nature, that's whenever JavaScript became less fun and Python seems to have a natural fit in that environment.

Miller Hooks: I would say that the zen of Python has made me a better programmer in all spaces. Python casually enforces you to think about the readability and the future people that are going to touch it. Naming conventions, the DRYs. It's not so much enforced, but it's just part of not only the language itself but the culture around the language. JavaScript, without that sort of guidance can turn into ... it takes a lot of care to be able to organize a JavaScript project and have it not eat you alive over time.

John Lindquist: Oh man, ain't that the truth. Yeah, I love the stupidest things. I love PEP 8, where mostly everyone agrees on how Python should be formatted and maybe if the JavaScript community could come together and say, "Hey let's all agree on something." That way would make it so much easier for beginners and so much easier for maintainability and readability and I assume, do you guys use PEP 8?

Miller Hooks: Yeah, absolutely. There's no Guido for JavaScript, we have to deal with JavaScript, it's thrust on us design by committee but Python really was able to grow from that by having one ideologue to build it up into the tools today and it really benefits from that but you can apply all that straight over to JavaScript, it helps.

John Lindquist: Will were you going to say something?

Will Button: I think the one thing that on the readability thing, I think just how open Python is about "Hey this is how ... These are our naming conventions and these are how you maintain readability." It's straight up front and you don't have to look for it and you don't get surprised about it and I think that's one of the cool things that you can do in JavaScript is just to make it much, much more accessible and easy to identify that there are standards for certain things.

John Lindquist: The example of showing a beginner a JavaScript book and then having them read some framework code from today in JavaScript. They look like completely different languages both because JavaScript has evolved so much and because of the many varying ways people write in JavaScript.

Miller Hooks: Functionally, they almost are. Angular and React, all these things are under the JavaScript moniker but when you say you know JavaScript that's not really a solid descriptor because there is so much variant in the particular silo that you're in just because of the nature of it.

John Lindquist: Yeah. I 100% agree and I think a lot of people learn a particular framework or something and just stick to that and they're more an Angular developer than they are a JavaScript developer. Have you seen that sort of case in Python, where someone's like a Django Developer rather than a Python Developer or do you think if you know Django, you know Python?

Miller Hooks: No, Django has definitely broken some rules as it's evolved into what it is today. For the most part, one of the ways that Python is designed is that it is very assessable on the surface because it reads like English and it's very functional but it goes as deep as you wanna go. It doesn't have that context switching really anywhere in it. There's been a lot of care to maintain that for sure.

John Lindquist: Let's do a comparison like, developing a node versus writing the server or whatever in Python. What do you find so appealing about Python in those scenarios?

Miller Hooks: Well for me, they really work in tandem but I live server side Python. If there is a server side task, if it's data based interfacing or operational scripting, Python is where I go to. Node is getting a lot better, I was just introduced to Lerna the other day and using that is now going to be a part of my server side operational stuff. Python as is, either 2.7 or Python 3 hopefully, is on almost every system. It's just as available and reliable as Bash probably is.

Miller Hooks: The early days of Node and NPM, specifically things like versions were really, really hard to work with and manage and through the original predecessor to NVM actually used Pythons virtual M to make versions of Node and I think their package manager takes lots of cues these days from ground that was set up by PIP after easy install. It really is, I would say even in the last six, seven months as the new Angular stuff and the eco system is maturing, they are starting to look similar but I couldn't say the same thing a couple years ago.

Will Button: Yeah, I think using PIP for deployments and just managing your dependencies is so much easier using Python and then just ease of deployment because, like Miller said, Python's already out there and it's just ready to go. The deployment process has a lot less friction, which isn't necessarily true for Node on the back end.

John Lindquist: Yeah, I think some people listening to this podcast might not know that your OS probably has Python on it, right. Any time you wanna start with a Node project, you have to first download and install Node, or include it in some sort of bundle or something.

Miller Hooks: And that is because there's fragmentation in every point version, which is inherent with the fact that our browsers are evolving so fast, and the tools around JavaScript ecosystem, which are so powerful and varied, but part of the Python deal is consistency and backwards compatibility. If you've got a Mac in front of you, or a Linux computer, it's just gonna be there waiting to operate and that's why it is one of my favorite intro languages, because it's on that computer.

Miller Hooks: I introduced my girlfriend to the Python interpreter, and I didn't realize she had a Netbook, but she was able to get it installed on her Windows Netbook and run through, learn Python the hard way, which that's really, really the hard way. I was really proud of her for getting after that. I had to open up the computer to realize it did not have a hard drive but it's still there, and just you can open up the interpreter, and walk through the lessons.

Miller Hooks: Part of getting good at JavaScript is a large obtuse understanding of operations, which isn't something a person who's just starting out to learn necessarily needs as a hurdle.

John Lindquist: Yeah, I 100% agree with that. You mentioned versions. I haven't touched Python in a little bit, and I know Python 2 versus 3 had been a thing back when I used it last. I think it's still a thing, right?

Miller Hooks: No, not really. Python 3 is everywhere. If a package hasn't upgraded, it's probably because it's dead and we even have a tool that comes with Python 3 that will convert a project for you, and lint it, and let you know if anything you need to address directly. So even a large project can be converted almost instantly. It also will help you if you have specific context switches, that it might be deployed on both, to be able to work with that. But largely, the entire ecosystem of anything that's even slightly actively used is imported.

Will Button: I think the only you still see Python 2 anymore is just in a case where people ... I think CentOS and AWS Linux still default to Python 2, and so if you have someone that doesn't know, or hasn't been experienced with Python, they may end up running Python 2, but those are pretty few and far between and Python 3 is just ready to go and everything is set up for it on almost all the modern OS'.

Miller Hooks: It's very good at error readability as well, which was always one of my biggest ... when I first started doing Node was ... and I'm still unimpressed at the signal-to-noise ratio and error messages, even though it has been getting steadily better with the newer versions but if you are running the wrong package on Python, you've got four or five lines that are gonna be pretty clear.

John Lindquist: Yeah, errors are so important. It's funny how often I just get used to them in JavaScript and I forget how nice they can be in other environments. Let's talk about what Python does really well that the JavaScript audience might not be familiar with, such as machine learning, or other areas. Are there things you guys are playing with or really enjoy that you'd recommend? Like, "This is a great reason to use Python."

Miller Hooks: I would say especially to the audience for this podcast that you'd be hard to be Django, and Django REST Framework for your backend. There's this great tool called Cookiecutter that has an intro Django, and there's a decent advanced one by Pydanny that literally with just one command, Django Cookiecutter, you can ... it'll ask you a handful of questions and it'll deploy you Django with Django REST Framework in and an angular setup, so you've got an API, and you can set it up for Heroku or Docker deployment.

Miller Hooks: Django can get out of your way and be the tool that you need to get to your ideas faster and with that ORM, you can start getting your blog handed over to your single-page application, and have things like token authentication, and a nice robust API, without spending all of that time because still in the JavaScript world, when you try to say, interface with Postgre or MYSQL, and you're trying to write an API, you're going to be doing it sort of piece meal.

Miller Hooks: Django has been designed from the get go for publishing and Django REST framework is really, really hard to beat, and I'd say anyone who's been doing JavaScript work for a little while can jump right into that tool and have robust backend with authentication, email, and easy data models that in JavaScript would be a piecemeal operation and harder to maintain. You really have to know where you're going.

John Lindquist: Right, and it has an admin section where you can just go in and ... with the GUI.

Miller Hooks: It is hard to beat that Django admin. I don't think anyone has that. It is zero to go. That was the original impetus of designing Django, it was designed for publishing and they wanted to get apps up with a backend so content producers could start adding content and the models could be flexible while the front-end was still being completed. It was about that speed of release and I will say that another thing that I'm sure exists in the JavaScript world but Django's had down for a long time is schema migration.

Miller Hooks: As we're gonna change our database tables, and you don't want to think about that, and you want to be able to roll them back and roll them forward, and that's built into the application so you can be adding or removing tables, doing data entry through the admin, creating fixtures for that data so you don't lose it and redeploying it very, very quickly.

John Lindquist: I think basically anything database related is better in Python with my experience. I remember just plugging in database names and table names as a string and then it just worked and in node, we'll have to install, this thing, that thing, that thing and then wait. What's this one? What's that? And, yeah.

Miller Hooks: I found Django 9.6 after I was Drupal developer. I'd been doing PHP for most of my career so it was quite a while ago. Drupal and WordPress and one of the largest automated attacks in history happened at the time and all of my websites were compromised all at once, and it was replaced with a man with a sword and some scary chanting music and all of my clients were sad and I mean, it's because the eco system of WordPress and PHP are huge attack factors, extremely vulnerable and it was very, very scriptable.

Miller Hooks: I had been looking at other Python frameworks, a friend had shown me the interpreter and then I found Django and as soon as I saw that ORM, I never looked back. I've done a little bit of WordPress since but I was able to port my customers over easily and I wasn't even proficient at Python.

John Lindquist: That's a great story. Will what are your thoughts on-

Will Button: I think that's one of the cool things you can learn from Django if you haven't been programming a lot, if you're just getting started with programming. Firing up Django and going through that process, it actually exposes you to a lot of things that you may not even realize or things you should be thinking about like the schema migration and how easy it is to get an admin interface up.

Will Button: It's a way to quickly and easily start testing out your idea, see instant results but at the same time, learning about some of the higher level concepts that are gonna be important for you to know as your project progresses and becomes more advanced.

Miller Hooks: Especially for people that are used to doing all the JavaScript, I mean, Django REST framework has been just an amazing project. It's exemplary and with 2.0 where it's integrating with channels, so we have sockets as well, but it's really turnkey. You add in Django REST framework, or you can use a Cookiecutter that already has it and so when you create your models, you get a REST interface with authentication so now your promises and everything just works.

Miller Hooks: Something that I've really been playing with this year is adding in Graphene or GraphQL. You can add that and for JavaScript people, that means there's no model duplication and that's been something that's been really hard to avoid is recreating the same code in two places and so if you can just make your models in your Python and then query it directly with GraphQL, it's fast and easy to maintain and get the information you want.

John Lindquist: That's something I need to try now. I needed something else to do. Any other things that new Python users should look into. I know that Django for sure is a ... the greatest feeling of learning something is producing something and going from zero to Django app for beginners is an amazing experience, which I wish we could replicate in JavaScript land but is there-

Miller Hooks: I would recommend the IPython notebooks, which are called Jupyter notebooks. Jupyter with a Y. If you have Docker installed on your computer, you don't have to know anything about Docker, but you can go look up the IPython notebook for data science NumPy, SciPy or just Python and you run one command, and it pulls down this container that gives you the IPython notebook is a web address, you can just browse through it in your browser, and it saves a specific type of file called Py ... I don't know. It's got a couple of letters in it but it's a ... it gives you a web interface where you can chunk out different cells of Python and hit run right there in the browser.

Miller Hooks: You can switch between two or three, you can have access to the data science tools, you can open up a terminal in the browser and install new packages with PIP. Without configuring your interface or your computer, you can get in and use some data science tools that otherwise you wouldn't have to and I think this really couples well with starting to learn because you can spin up an IPython notebook instance right there on your computer, you get this webpage that works just like a notebook and then you can open up learn Python the hard way and just go and work through those exercises and you can just replay each cell and then you can open up a new one and play with some of the harder tools, which leads itself right into being able to set up a Django site easily.

Miller Hooks: It's just an amazing set of tools. I use it all the time when I need to scratch pad something. I just open up the container and play around with it.

Will Button: That's great. One of the cool things I like about that as well is you can have not only your Python code in there, but you can also have documentation in there. You can add markdown or HTML and so you have this little running transcript of here's the chunk of Python code, you can run it and then just have the documentation of this is what we expected the outcome to be or here's what we're gonna do next with it and then another chunk of Python code and it's actually been really helpful for me, working with finance departments because they question everything, they question every assumption.

Will Button: Where did you get this data from? What assumptions did you make in cleaning the data? How did you model it out? And you can just create this whole beautiful step by step interactive document to give to them and they can reproduce your results and see the documentation in line with it.

John Lindquist: That sounds awesome. Have you guys seen Python influence JavaScript in any way? Do you think any of the ideas in-

Miller Hooks: NVM for sure because it started out as that and the isolation that comes with that I do believe is fairly Pythonic.

John Lindquist: Anything from the language itself? When you get into JavaScript land, is there something you just miss dearly from Python, just simply cranking out code?

Miller Hooks: Probably not intro but Lambda functions and generators, being able to have the tuple data type and also nothing is statically typed. Everything is everything, which has its own pitfalls too, but it does ... when I can just change up a variable and its contents easily and be able to overload it, which there's definitely ways to do it, it's just in JavaScript, it's just the way that Python does that I think really lends itself especially early on when you're trying to learn.

Miller Hooks: Sometimes all the different data types can get really confusing and it doesn't mean you don't need to know about them but Python gets that syntax out of the way, so you can move your things around and I think that's something that ... because it's from the paradigm of Python readability and I do miss that and it encourages me to be more fastidious in my JavaScript. That's for sure.

Will Button: Yeah. I think the readability of Python is just something that I don't see whenever I look at JavaScript, even whenever I write my own JavaScript, it just feels really hard to get that level of readability into JavaScript as you get by default with Python.

Miller Hooks: One of the jokes with Python is that it's self-documenting because the code is the documentation obviously, auto doc is still important, but it does just read. If you have a problem you can just jump in there where it can be a little esoteric in most other languages.

John Lindquist: Is there any concrete examples you could give of that? Some put a comparison between what in Python ... what does a call back look like in Python?

Will Button: You just don't have them. If you write a function that has to go off and query a server and return results, you just handle the results on the next line because the code doesn't progress until that line of that code above it completes.

Miller Hooks: Async Python is pretty cutting edge and people that are really looking for an asynchronous Python experience, if you're really interested in digging into the nuts and bolts of Python, look at the debate about the GIL which is-

John Lindquist: The GIL?

Miller Hooks: GIL yeah, the Global Interlock, which is why Python doesn't do asynchronous well. We have some async tools and there is a project called the GIL-ectomy about removing this I think the Global Interpreter Lock from Python, so it can work concurrently and one of the debates about that is if you need concurrency, then we have Rust and Go and those play fine with Python but traditionally, the async tasks that are some of the hardest things in other languages because they inherently involve not really knowing what's going on on the other side, Python avoids for the most part.

Miller Hooks: If you've got a bunch of async calls in your Python, either you know what you're doing or you're very frustrated.

John Lindquist: Yeah, I can get that. One thing I've noticed with Python is one of my friends, she's a ... she does data entry and as part of her job, she had no experience programming whatsoever and then as part of her job, just as she got into it, they were like, "Well, is there any way to automate any of these things?" She was introduced to Python through just automating her daily routine data entry points and similarly, I have another friend who's working on his engineering degree where they needed to compute some sort of physics whatever, I'm not into Math and the first thing he turned to was Python because that had the best Math libraries for calculating all these interactions in the physical world.

John Lindquist: It seems like there's so many day to day things where JavaScript seems to have focused on the web but there are so many day to day things that Python solves so well that people just stumble onto to use it.

Miller Hooks: Over the last few years it really has become the darling of data analysis. It started in academia but now it's moving into big data which before had preferred things that were more esoteric and that has a lot to do with IPython notebooks and a project called Pandas and then also the readability and accessibility like we were talking about the ability to share these things but I use Python every day to script out annoyances. If I have to repeat something too much and it's complicated, I open up some Python and if I'm on a new job or something, I automate the hardest parts of it with Python fast and that's because-

John Lindquist: Give me a good example of that. What's something you've automated?

Miller Hooks: Sure. I was at a large video streaming company and they were an entirely PHP shop and everything had to be routed through a VPN and the VPN was all the way to Luxembourg and it would go down a lot and one of the things ... They said it was basically impossible to do local development using Docker and a few other things, I was able to get that going but a constant problem for me was this Mongo service that I didn't have access to but it relied on through the VPN.

Miller Hooks: Through some man in the middle attacks on my own stuff, I was able to dump that data, parse it and create a fake service but there's easier day to day tasks like for instance, you have a ... someone gives you a giant spreadsheet and you could load it into Google Docs, the G spreadsheet package for Google Docs. If you've just got a quick ... You don't even need an API key, Google gives you a special email address and you dump that as the string. You open it on IPython notebook and then in that IPython notebook, you now have access to that total ... that Google sheet where you can reference the columns by name and if you start playing with Pandas or any of the libraries there, you can parse all that data out and do exactly what you need and then from Python, you can have ... just make a separate cell with a play button that will push that out to a CSV or your other server.

Miller Hooks: That's without knowing anything about network infrastructure. You can automate a task that would be manual. A lot of hidden data in and out of spreadsheets that we deal with on a daily basis can be very kludgy.

John Lindquist: That's so cool. I take that for granted so often. Just the automation of simple spreadsheet things that my parents try and deal with all the time and just waste so much time with and-

Miller Hooks: So much of large enterprise operations run on two women above 70 years old sitting in a room with dusty books and spreadsheets and hold all the institutional knowledge and a lot of it is emailing spreadsheets around and when you really get into those businesses, a lot of their cost are out the window for that. Now, we do have tools for that sort of thing and at any new job, that's the first thing I look for is ways I can script easily the hardest parts and then just let people know that I'm very efficient and they don't have to see the scripts, they just think I manage it.

John Lindquist: Sounds like you should charge more.

Miller Hooks: I do okay.

Will Button: I think that's a [inaudible 00:26:37]. One of the things that you can do is that any time you have this daily repetitive task, if you have to move this file or copy and paste this data or run this report they're all tests that can be really easily automated by Python and a great learning experience to. You can take this task and you can automate it and then the deployment of it makes it easy because Python is gonna exist somewhere in your environment where you can push that and just have it run every day and completely automate that task away and it's pretty amazing when you dig it's pretty amazing when you dig and just do a little bit of research.

Will Button: The libraries that already exist for Python that read spreadsheets or write spreadsheets or send emails. All of those daily tasks that people build their whole jobs around can just be automated away.

Miller Hooks: I don't know how many times before I really discovered the power of Python, how much time I would spend with things like figuring out how to parse things like figuring out how to parse CSV and figuring out how to parse CSV delimiters. Who really needs to hold that knowledge in their head [inaudible 00:27:42]? A good tool for intro to just that process. People are looking to use that as kind of an entry way into ... it's called Fabric. It's a Python library you create as fab file py and I do this in just a working directory and kind of similar to bash.

Miller Hooks: You can just execute commands in the terminal with it and you create functions with them and then you just end up with little keyboard shortcuts. So, you do fab, the name of the function and you can set it up to execute remotely or locally, it can access other servers and it's continuous integration to use a big annoying word but at a level that's really accessible. You don't any infrastructure and I'll use it for producing reports for people. I think that's a pretty good swath on what it is and what the introduction is.

John Lindquist: I think for our audience it's pretty much ... I don't like to go too deep into-

Miller Hooks: I can annoyingly talk about really esoteric stuff but everyone in my life has told me to stop.

John Lindquist: That's for listening. For more information, check out will's intro to Python course on