Brought to you by Talk Python Courses and Six Feet Up consulting

#8: Python gets Grumpy, avoiding burnout, Postman for API testing and more

Published Tue, Jan 10, 2017, recorded Tue, Jan 10, 2017
0:00
00:20:48

This is Python Bytes, Python headlines and news deliver directly to your earbuds: episode 8, recorded on January 10th, 2017. In this episode we discuss Python is Grumpy, avoiding burnout, Postman for API testing and more.

#1 (Brian): Jessica McKellar, "Breaking The Rules", PyBay2016

  • Jessica
    • was directory of PSF for several years, was involved with Boston Python UG, is diversity chair for PyCon, is an engineering director at dropbox
  • Powerful keynote
    • Her extra work with Python is not about Python, it’s about studying systems.
    • “Learning how to program changes the way you think about, debug, and interact with the world”
    • “You learn a set of rules to build software, … then you learn that you can change the rules.”
    • “Programmers master a system they know they can change.”
    • “This comes from the tenets of free software.”
    • “We take for granted that changing something to make it better is just a thing you do when you need to.”
  • This can and should carry over to the rest of your life.
  • Jessica takes this idea and applies it to politics, voting, and polling stations, and ran a polling station herself.
  • That’s pretty incredible. About half the time is Q&A with some great questions.
  • Listen to this talk and apply it to every part of your work and life.

#2 (Michael): Grumpy is a Python to Go

  • By Dylan Trotter from YouTube
  • Grumpy is a Python to Go source code transcompiler and runtime.
  • intended to be a near drop in replacement for CPython 2.7
  • The key difference is that it compiles Python source code to Go source code which is then compiled to native code, rather than to bytecode. This means that Grumpy has no VM.
  • 6,000 stars on Github in 3 weeks
  • Look for him on Talk Python To Me (episode 95?)

#3 (Brian): Finding dead code with Vulture - Dougal Mathews

  • pip install vulture , then vulture some/directory/of/code
  • Reports unused code.
  • vs coverage.py. You can get similar information from coverage if your test suite or the code you run during the coverage inspection is fairly complete. However, what if a unit test is the only thing calling some function? vulture allows you to exclude your test code when looking for unused code.
  • vs static analyzers like flake8. With some of my own code that I have in progress, vulture found the same stuff that flake8 did. However, if you are only looking for dead code, it’s easier to find with vulture if you have other flake8 violations. Also some folks don’t like style checkers.
  • I’d like to hear what other people think. But I like the idea of having a focused dead code tool. And vulture is a great name for such a tool.

#4 (Michael): Postman: Developing APIs is hard. Postman makes it easy

  • A powerful GUI platform to make your API development faster & easier, from building API requests through testing, documentation and sharing.
  • Cross platform and free
  • A simple and effective way to share details about your public-facing API
  • Testing
    • Run Postman Collections directly from the command line
    • integrating with continuous integration servers and builds
    • Monitor uptime, performance and correctness of your APIs.
  • Notable mention goes to paw.cloud (macOS only)

#5 (Brian): The Reality of Developer Burnout by Kenneth Reitz

  • Author of Requests and of Maya (datetime for humans), covered in the last episode.
  • This is an article about getting overwhelmed as a maintainer of an open source project. But applies to anyone supporting a tool, even for your coworkers. And really applicable to all sorts of developer burnout.
  • Advice:
    • Keep producing, but stop consuming so much on social networks. twitter, reddit, etc.
    • Delegate more.
    • Have hobbies other than coding
  • side note:
    • On the maya github page, I noticed a link saythanks.io, a Kenneth project where you can set up a way for people to just send you a thank-you note. I think this is cool. I wrote about the power of “thank you” a few years ago. It’s really important in open source, and really all the time.

#6 (Michael): Jinja 2.9 Released by Armin Ronacher

  • From Hugh Blandford (thanks!)
  • New release, 2.9 codename "Derivation" of the Jinja template engine for Python is out
  • While Jinja2 supported Python 3 for years now it never really embraced functionality that the language provides on 3.x that it does not do on 2.x
    • However 3.6 now added async generators which permits Jinja2 to fully support the async and await keywords on 3.6 and later.
    • In particular it means that you can now return coroutines from functions passed to Jinja2 templates and the template engine will automatically await them.
    • Likewise all filters were updated to work with iterators as well as async iterators alike.

Episode Transcript

Collapse transcript

00:00 This is Python Bytes, Python headlines and news delivered directly to your earbuds.

00:04 It's episode 8, recorded January 10th, 2017.

00:09 This is your host, Michael Kennedy, along here with my co-host, Brian Okken.

00:12 Hey, Brian, what's up, man?

00:13 That's going really good.

00:14 Yeah, glad to hear it, glad to hear it.

00:16 We're, I kind of feel like everybody's still kind of getting going after the winter break.

00:21 I know, you know, we're both in Portland and we've been like, our world has been covered in ice repeatedly recently.

00:26 So it's been a bit of a strange start, but there's still Python news to talk about.

00:31 Yeah, there is.

00:32 I'm going to start with, actually, there was a PyBay 2016.

00:37 I actually don't remember when that happened.

00:39 It was sometime in the fall.

00:40 I want to bring up one video, which is from Jessica McKellar titled Breaking the Rules.

00:47 From the talk, it sounds like it was pre-election, but so at least it was in the fall.

00:53 But yeah, the video came up in December.

00:55 I was listening to it and was kind of blown away.

01:00 So Jessica was the director of the Python Software Foundation for several years,

01:04 and she's been involved with lots of stuff like the Boston Python user group,

01:09 and she's the diversity chair for PyCon.

01:12 I guess she's an engineering director at Dropbox, which just sounds cool.

01:16 But anyway, this was a keynote speech or a talk, And she was talking about all of her work with Python was not really about Python, but about studying systems.

01:30 And here's some cool quotes.

01:31 Learning how to program changes the way you think about debug and interact with the world.

01:37 And you learn a set of rules on how to build software.

01:40 And then you learn that you can change the rules.

01:43 And programmers master a system that they know they can change.

01:47 And these sorts of comments that she talks about, I guess I knew, but I didn't really ever think about it before.

01:54 And she takes it and she realizes that as programmers, we often take it for granted that if we're using a tool that we want to make better, we can just go in and make it better.

02:06 It's an open source thing.

02:07 And that this should carry over to the rest of your life.

02:11 She takes the idea and applies it to politics and voting and stuff.

02:17 I guess she ran a polling station by herself and her husband did a different one, which actually is pretty cool.

02:23 But it's neat to hear somebody firsthand say it's not that hard to get it done.

02:28 But I like the idea of thinking about how the programmer mindset and how you can change the system that you're working in.

02:37 And I think more people should apply that to their workplace a little bit.

02:41 that I hear about people that are unhappy at their job and they like a cubicle farm or something

02:48 and they get out and do an entrepreneurial thing. And that's great for some people.

02:54 But for others, I think maybe it's better to look at the system and realize that you're part of it

03:00 and try to make it better yourself. Picture yourself in your manager's shoes or your manager's

03:05 manager wouldn't you want to hear from all of the employees if there's something you can

03:10 that could happen to make it a better place yeah i think it's i think it's a great message i think

03:15 i really like jessica's work and i actually had her on talk python on episode 30 and she's she's

03:20 done so much for diversity and the way the python community actually is today like 10 years ago it

03:27 was very different yeah one of the things that she brought up in that talk was that i think she said

03:33 five years ago, but not, let's say a handful of years ago, the number of women speakers at

03:38 Bicon was like 1%. And now it's like in the 30s, maybe low 40s percent. It's, you know,

03:46 traumatically different. And there's a lot of changes like that, that she was central in. So

03:50 I think she does a great bunch of work. In that video, one of the, that was one of the questions

03:54 is how did she do that? And it's, the answer is awesome. She just emailed a lot of people and asked

04:00 them to submit talks. Yeah. And sometimes, you know, you just got to ask, right. And you want

04:06 the world to be a different way. Sometimes you just have to ask or take the first step or whatever it

04:10 is, right? Like I think two, two ideas that sort of come to mind as you said that one is there's a

04:18 quote that goes something like this from Steve Jobs, like the world around you was made by people

04:22 no smarter than you and you can change it. And once you realize that, like you can't just accept

04:27 the world the way it is, you see that you can change it and you kind of must, right?

04:31 And the other is, I really liked the notion of once you learn to program, you control the

04:38 system as much as it controls you and you can change it and you start to apply that thought

04:42 to the greater world.

04:44 And I think that's really something valuable that people that are on this learn to code,

04:48 teach kids to code mission don't get, but would be a powerful benefit to students and

04:54 just everyone.

04:55 And it's another reason to teach everybody, more and more people to code.

05:00 We don't have to generate an entire generation of programmers, but a generation that actually understood how computers work would be good.

05:08 It wouldn't be bad.

05:09 Yeah, I definitely think the world needs more creators, fewer consumers,

05:13 but not necessarily more programmers, right?

05:15 You know, people say that I'm a pretty happy guy, pretty optimistic guy,

05:21 maybe to a fault sometimes, but usually people don't say I'm grumpy.

05:26 but today I'm feeling a little grumpy. Actually, I'm feeling grumpy also.

05:31 Yeah. And grumpy, this time grumpy is good. I think grumpy is good. Grumpy is interesting. So

05:35 the guys at YouTube, particular guy named Dylan Trotter wrote a blog post on the Google blog,

05:42 tech blog. I don't remember exactly which one, but it's in the links called grumpy is a Python

05:48 on Go interpreter or runtime. So at grumpy.io, there it redirects to the GitHub repository,

05:55 they've built this thing, and it was released really recently, like three weeks ago. And what

05:59 it is, is it's a transpiler, it takes Python, legacy Python, sadly, so cpython27, and it compiles

06:07 it or transpiles it into Go code, which is then compiled and run on top of the Go runtime. So

06:18 interpreter. Two, it executes purely as Go. So all the features, and I really think the reason

06:25 they're doing this is the concurrency story around Go and maybe even a migration story. We'll see

06:30 about that. But there's a lot of interesting things that they can do if they can get Python

06:36 to run on top of Go. Yeah. So one of the things that also caught my attention about this is this

06:42 seems to have really taken people, captured their enthusiasm because it's on GitHub. They announced

06:49 it a few weeks ago and it already has 6,000 stars, right? For a project that's a few weeks old with

06:55 6,000 stars, that's pretty amazing. So I'm actually having Dylan on Talk Python To Me on episode 95,

07:01 which I think comes out next week. So look for a bigger story there.

07:05 So is that one that's already recorded?

07:07 No, I'm going to talk to him Thursday.

07:09 So do you know what the reasoning?

07:11 I mean, I get why you'd want Go for Python stuff, but why is the language Go not enough

07:18 and the Python language easier to write in?

07:21 Well, I believe, I don't know.

07:23 There's certain things that they can't talk about or don't want to talk about,

07:26 so I don't want to read too much into it for them.

07:29 Okay.

07:29 But Go is big at Google.

07:32 YouTube right now, the front end for YouTube is written in CPython 2.7.

07:38 So I would speculate that they're thinking of how do they not stay on Python 2.7.

07:44 Yeah.

07:45 Okay.

07:46 Yeah.

07:46 Pretty interesting.

07:46 You know, another thing that would make me grumpy, not in the Python way, but really grumpy is when I'm given a huge project, like, you know, tens of thousands or hundreds of thousands of lines of code.

07:58 And they said, here, look through this and understand this code base.

08:01 And I look at some method or some set of classes.

08:03 And I'm like, I don't understand what effect this has.

08:06 It seems to do nothing in this code.

08:08 And yet here it is.

08:09 And I'll tweak it and play with it.

08:11 And it doesn't even seem to have any effect.

08:13 And then I realized that code is never called.

08:15 Yeah.

08:16 Hopefully, it'd be cool if there was a way so you could find some dead code.

08:20 You mean like if there was like a creature that could like soar through the sky

08:24 and then would find these bodies and like consume them and they would be gone?

08:27 Something like that?

08:27 Yeah.

08:28 Yeah.

08:28 Maybe.

08:29 Or maybe we could have like a cheesy Segway bot.

08:33 But anyway.

08:34 Exactly.

08:35 There's an article by Dougal Matthews called Finding Dead Code with Vulture.

08:41 And Vulture is a Python tool that you can install with just pip install Vulture.

08:46 And it's really easy to use.

08:48 I downloaded it, applied it to some code I was working on.

08:52 And you actually can just point it to a directory and it looks at all the Python code there.

08:57 And it tells you, I'm sure it analyzes stuff and does call trees and whatnot.

09:02 I don't know how it works.

09:03 But it gives you a list of all the functions and variables and lines of code that are not used.

09:09 It was just really fast and really easy to use.

09:11 I liked it in the comment from Dougal.

09:15 There's some people that use really aggressive unit testing and TDD strategies,

09:21 which makes it such that every function is going to have a test for it.

09:25 But what if that internal function isn't used by anything else?

09:29 Well, there's a way you can take your unit tests and exclude them from the vulture.

09:34 which is kind of neat. I was thinking about the comparison. Normally I would find this sort of

09:40 stuff by using Flake 8, but like the example you gave, you wouldn't want to try to convert,

09:46 fix all the PEP 8 errors and things just to find dead code. So this might be a good use case for

09:53 that. And also there are some people that don't like static analyzers like Flake or whatever.

10:00 The other comment was that coverage, if you're running coverage over your code with your tests, that should tell you that parts of the code aren't used also.

10:12 However, your test suite's got to be fairly complete in order for you to really be sure that that's true.

10:18 Yeah, it's tough to do it with coverage and testing, I think, because like you alluded to, there might be some function that is never called,

10:29 but you might have written a test about it.

10:30 So then it kind of looks like it's live again, right?

10:33 And the thing where I find this to be really insidious is I'm looking at some function

10:39 and I realize if I take it away, this other function depends on it.

10:43 And if I were to take that away, another function, and then maybe like three or four or five function calls back in this chain.

10:49 These are all kind of dependent on each other, but nobody ever calls the first one.

10:53 And so it's really hard to tell, like to follow all those chains and determine like,

10:57 actually this whole branch of code that you're trying to deal with, just forget it.

11:00 It's gone.

11:01 You have source control.

11:01 Delete it.

11:02 Yeah.

11:03 That's pretty cool.

11:03 I like it.

11:04 Yeah.

11:04 Yeah.

11:05 They did warn about false positives saying something wasn't used when actually it was.

11:10 So be a little careful, like, you know, systems that use conventions like,

11:16 you know, pyramid or Django or something, right?

11:19 You map a route to a thing and it doesn't look like you ever call that thing,

11:22 but obviously it's called by, you know, a URL, right?

11:25 So, so just be aware, be aware of those sorts of things.

11:27 of things but yeah it looks really cool speaking of tools that are cool you know i i don't get much

11:33 meaningful mail these days but i do like this thing called postman yeah postman at i think it's at

11:40 getpostman.com is a cross-platform gui app that lets you test and visualize and play with apis

11:51 i love my apis yeah so i've actually been doing some things that required me to write some apis

11:57 and I'm like, you know, obviously I could go into the dev tools in my browser,

12:01 or I could write some, you know, some command line thing to test them.

12:04 But this is really nice.

12:05 You can like create, you know, here's how I call this function as an authenticated user with this data.

12:10 And you could actually save that in this UI, and you can even create them and share them across teams,

12:15 integrate these into continuous integration for like testing deployments

12:20 or like integration tests of your whole system.

12:24 It's really cool.

12:25 It's free.

12:25 It's cross-platform.

12:26 It's not written in Python, unfortunately, but, you know, it's still a really cool, cool system.

12:31 Question about that.

12:33 When you say API, is that you're referring to like a REST API or some other web API?

12:39 Yeah, yeah.

12:39 It says APIs, but I should maybe make it really clear.

12:42 Those are services like HTTP services, SOAP services, things like that.

12:46 Okay, great.

12:47 Yeah, yeah.

12:48 Not like APIs, like pip install this package and then call this function.

12:52 Yeah, well, you know, when I'm testing or running on developing a new API,

12:56 Sometimes it's tiring and I kind of get burned out on it.

13:01 Yeah.

13:02 You know, you and I have been programming for a long time.

13:06 And I don't know about you, but I've certainly gone through a period or two where I'm just like, more of this.

13:12 And it usually depends a little bit on the project.

13:15 It's not really the programming.

13:16 It's kind of like all the other stuff, you know, nitpicking at your time and energy.

13:21 And so Kenneth writes, I'm going to keep going with writes, not reads until I hear otherwise.

13:26 Kenneth writes, does a bunch of great work.

13:28 He's the For Humans Guide.

13:29 We talked about Maya last time, right?

13:31 Yeah, last episode we talked about Maya and he's, of course, the author of requests.

13:37 But he wrote this article called The Reality of Developer Burnout.

13:41 And I'm glad he did it.

13:43 I had heard that he was, I don't remember last year or something, suffering from just like burnout

13:50 of being the main support person for an open source project.

13:55 Yeah, and he's not the only one.

13:56 Like, gosh, I can't remember the guy's name, but he's in Lawrence, Kansas.

13:59 He's one of the founders of Django.

14:01 Also just got totally burnt out and had to just step back.

14:04 And I remember there was like a half hour conference presentation that was kind of like a goodbye

14:09 or something to that effect, if I'm remembering it correctly.

14:12 But yeah, there's plenty of stories of people getting not just requests,

14:17 but like angry email for stuff they're doing for free.

14:21 Right, open source projects and so on.

14:23 Definitely.

14:23 And I think I don't maintain a large open source project, but definitely maintain tools within our company.

14:31 And I think a lot of people can relate to some of the things that Kenneth talks about in Burnout in this article.

14:38 But I think he has some decent advice.

14:41 Some of the advice he gave was to just keep producing, but possibly not at the same speed.

14:47 But stop consuming so much on your social networks.

14:51 He, he like disconnected from Twitter for a while.

14:54 He didn't quite pull a four 10 gone.

14:57 Right.

14:58 But, but like, just stop following people, stop looking at it so much.

15:02 And, and then he also talked about delegating more, trying to, it is a community.

15:06 So try to get other people of the community to take over a lot of the roles that he had within the request community.

15:13 And, and, and then also generate other hobbies.

15:17 Don't do all of your free time just doing coding.

15:20 There should be some non-programming hobbies.

15:23 I thought it was a great article.

15:25 And I was poking around trying to get links for the show notes.

15:29 And I came across when I was looking at the Maya, the GitHub page on Maya.

15:36 And it said, say thanks to Kenneth.

15:39 And I had never seen this before.

15:41 But apparently there's a saythanks.io that's a Kenneth project.

15:46 that it just sends a little thank you note to the person that set it up.

15:52 So I thought that was a cool project.

15:54 Yeah, yeah, that's really awesome.

15:56 So for our final one, our final topic brings us snapping back to the future,

16:02 away from Grumpy and Python 2.7, back to current Python.

16:07 Yeah, and hopefully you're not burnt out on template languages.

16:13 No, I'm still a big fan of server-side.

16:16 templated web applications. And one of the real popular ones is Jinja, Jinja 2 by Armin Roeniger.

16:22 And he's the guy behind Flask. And he just released Jinja 2.9. This is really cool. And

16:28 thanks to Hugh Blanford for sending us a note to say, here's a cool thing you should talk about on

16:35 Python Bytes. So here we go. And one of the things that stood out both to Hugh and to myself

16:41 was the deep integration with Python 3.6 and the asynchronous concurrency story around that.

16:49 Armin says, while Jinja 2 supported Python 3 years ago, it never really fully embraced the Python 3 features

16:55 because they wanted to make it basically lowest common denominator so it would work on Python 2 as well.

17:00 But now they say that it actually supports async generators, which fully support the async and await keywords.

17:09 So it means if you pass some kind of generator that is an async generator to the template and it's going to loop over them, it will await it as it does that, which is fantastic.

17:21 That's just so cool to see async and await and the concurrency flow all the way to the HTML.

17:27 So where would this affect it?

17:30 When does the template engine end up doing coroutines?

17:33 Well, yeah, so the template engine runs after your view method, your action method runs, and you pass back the model.

17:40 But the thing is, the model itself could have a collection that is a generator.

17:45 And normally you would just loop over it, right?

17:47 So I've got some kind of set of results, and maybe that came from a database query or computing it from a service, who knows.

17:54 And you're going to do a for loop over it and generate a bunch of 10, 100, whatever little sub-HTML pieces in your template.

18:04 Well, even if that was asynchronous, it wouldn't treat it that way.

18:06 It would just call it before.

18:08 So now it can do this in an awaitable way.

18:13 So my understanding is that if each one of those steps has to go to file or network or something,

18:19 or it's like a database query and it's sort of flowing through as you pull the items out of the generator,

18:26 it will free up the thread to go do other web requests while that part is running,

18:31 whereas before it would.

18:32 Oh, that's very cool.

18:33 I like it.

18:33 Yeah, it's quite slick.

18:35 Quite slick.

18:37 Another week in the Python world and we have a bunch of cool stuff.

18:41 So, you know, if you're using Jinja, get the new version.

18:44 If you're feeling burnt out, check out Kenneth Wright's things.

18:46 If you're doing APIs, check out Postman.

18:49 Bring out the vultures on that legacy code and check out Grumpy as well.

18:53 Lots of cool things.

18:54 And system programming as a larger concept with Jessica.

18:59 These are good things to check out.

19:00 What's going on with you, Michael?

19:01 Do you have any news you want to share?

19:02 Oh, I don't really have too much news.

19:05 I'm just working like crazy on a couple of projects.

19:08 Some stuff that I'm doing got me interested in Postman.

19:11 I'm doing a bunch of API stuff right now for a project that I'm working on,

19:15 but nothing I'm ready to talk about.

19:17 How about you?

19:18 How's the book?

19:19 it's, it's getting closer and closer to a, we're now, targeting a, hopefully a beta release for PyCon, but I am, I have a handful of people I'm going to try to, to, to get ahold of to, to be beta readers and, not just not beta readers, but, technical, consults, to technical editors to just read through it.

19:42 I think it's a couple week thing, but if anybody's listening and feel that they really want to

19:47 contribute to making sure I don't make any pie test mistakes, yeah, hit me up and I'll put you

19:53 on the list. Yeah, that sounds great. Get early access to the book. And are you giving them credit

19:58 till they get like a little thanks to? Oh yeah, definitely. And it's all handled through

20:04 Pragmatic. So there's a limited number of people. So I don't know how many people they'll pick,

20:09 but I want to give them a bunch of names.

20:12 Excellent.

20:12 Well, glad to hear it's still moving.

20:14 Yep, thanks.

20:15 All right.

20:15 Thanks for sharing your stories with me and it was great to chat with you and with everyone.

20:20 Oh, yeah, thank you.

20:21 Yep, bye.

20:21 Talk to you next week.

20:24 Thank you for listening to Python Bytes.

20:25 Follow the show on Twitter via at Python Bytes.

20:28 That's Python Bytes as in B-Y-T-E-S.

20:31 And get the full show notes at pythonbytes.fm.

20:34 If you have a news item you want featured, just visit pythonbytes.fm and send it our way.

20:39 We're always on the lookout for sharing something cool.

20:42 On behalf of myself and Brian Okken, this is Michael Kennedy.

20:45 Thank you for listening and sharing this podcast with your friends and colleagues.


Want to go deeper? Check our projects




Subscribe to Python Bytes