Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book


Transcript #83: from __future__ import braces

Return to episode page view on github
Recorded on Wednesday, Jun 20, 2018.

00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:05 This is episode 83, recorded June 20th, 2018. I'm Michael Kennedy.

00:09 And I'm Brian Ockin.

00:10 And Brian, we have a special guest, don't we?

00:12 Yes, we do.

00:12 Yeah, so Chris Medina is here to join in the fun and share his perspective on things.

00:17 Hey, Chris, welcome to the show.

00:18 Hey, guys, how's it going? Good to be here.

00:20 Yeah, it's good to have you.

00:21 And I also want to say thank you to DigitalOcean.

00:23 They are a major, major sponsor of the show, and they're sponsoring this one as well.

00:27 I'll tell you more about them, but the short version is pythonbytes.fm/DigitalOcean.

00:32 Get $100 credit for new users.

00:34 Brian, speaking of new users, people learning Python, they might want to set up a server at some point.

00:39 Set up a server?

00:40 Well, you know, eventually, they'll have a website or something, right, once they learn to code.

00:45 But you've got a really nice way for them to get started.

00:47 I've always been reluctant to try to look or play with some of these beginning code editors,

00:55 because part of learning how to code is learning an editor.

00:59 But I'm kind of warming to the idea of some of these specialized editors.

01:03 And there's one that I wasn't familiar with, which is Mu.

01:07 I think it's Mu or Mu.

01:09 I don't know.

01:09 Emu.

01:10 Code with Mu.

01:11 It's got a whole bunch of people on board.

01:14 If I go to the...

01:15 I can't remember where it is, but there's a bunch of people working on this.

01:19 And it's kind of a neat little editor that has...

01:23 I was playing with it this morning.

01:24 And it has some...

01:27 You just open it up, and it has built-in right off the bat.

01:29 It asks you if you're going to do it for Python 3, or if you're targeting, like, an Adafruit chip or a micro bit.

01:36 So it has built-in targeting of those things, like, right away.

01:39 And there's, like...

01:41 Along the top, there's some icons for loading and saving files, running it, debugging it, popping up the REPL, interacting with the plotter.

01:51 And then there's a...

01:52 Even there's a theme button, so you can jump back and forth between dark theme and light theme.

01:57 And it even has, like, a linter built-in where you can check things.

02:00 And it's all...

02:02 Like, you don't have to memorize any key sequences, or there's not really any menus around.

02:07 It just is all up there.

02:09 And I think this would actually be great for teaching people how to code.

02:13 So I'm going to start using it for, like, demos and stuff.

02:17 It's pretty cool, yeah.

02:18 So as you type, basically, it pulls up both the completion for the arguments that go to a method or something,

02:25 but also the documentation, like, while you're typing.

02:28 So, you know, you might get annoyed with that if you know what you're doing.

02:31 But if you're new, it's really cool to show you, like, hey, you can call these various things.

02:35 And here's the arguments.

02:37 Here's what it means.

02:38 And it even has a debug.

02:39 It's pretty cool.

02:40 So it's a separate app?

02:41 Yeah, it's a separate app.

02:43 But you can...

02:44 There's an installer available.

02:46 So you can just...

02:47 You don't even have to tell people about pip right away, because you can just install it with an installer.

02:53 But you can install it with pip, because it's just a Python thing.

02:56 I think it's a Qt application.

02:58 I've been corrected.

02:59 It's a Qt application.

03:00 Oh, that's really cool.

03:02 It's cute.

03:03 Okay.

03:03 Yeah, I installed it with pip.

03:05 And then one of the things that it has in the installation instructions is instructions on how to use...

03:12 So when you install it with pip, you get, like, a command line invocation to invoke it.

03:17 But it recommends using another package called shortcut, which you just...

03:23 If you pip install shortcut, you get shortcut moo editor, for instance.

03:27 And it'll create...

03:28 And it'll create...

03:28 On my Mac, it created a...

03:31 It just went ahead and created a shortcut in my launchpad to launch it.

03:36 So I didn't...

03:38 Oh, that's pretty cool.

03:39 So you can attach that to any Python script.

03:41 You can just launch it from there.

03:43 So...

03:44 Nice.

03:44 Oh, but...

03:45 It looks like it has different modes, too.

03:47 Like, you can set it up to work for writing code for Adafruit or for Pygame or stuff like that.

03:52 That looks kind of neat.

03:54 Yeah, and then when it has...

03:56 The built-in REPL, if you pop open the REPL, it's not just your normal REPL.

03:59 It's a Jupyter notebook or Jupyter REPL, which is pretty cool.

04:04 Yeah, that's really cool.

04:05 I love this.

04:06 Yeah, it's very neat.

04:07 And there's some...

04:08 Like, on the tutorials link, there's a whole bunch of tutorials that aren't quite there yet.

04:14 So I'm guessing they could use some people to help out with this project.

04:18 Oh, right.

04:19 Yeah, and that'd be a great, easy way to get...

04:20 Sort of gets your feet wet and open source is to write some tutorials.

04:24 Right?

04:24 You don't have too much to depend upon or you probably won't break anybody's code by writing one.

04:29 Yeah.

04:29 Yeah, nice.

04:30 So, Chris, one of the things I find that's pretty interesting is we love to talk about super advanced topics,

04:37 but a lot of times it's really what people need or want, especially if you're helping or mentoring someone else,

04:43 is like some more fundamental stuff, right?

04:45 Yep, I found this kind of an intro topic into how the Python parentheses system works.

04:52 It's pretty interesting also for folks that come from other languages, so you can get kind of like a quick translation from one place to another and how things operate.

05:01 It sounds pretty simple.

05:02 I mean, it's about Python parentheses, right?

05:04 The Python parentheses primer from Reuben Lerner.

05:07 Shout out to him on that.

05:09 But there's some pretty advanced things going on and a pretty cool feature coming at the end.

05:15 Great.

05:15 So, tell us about it.

05:17 So, the fun stuff is it goes into all the different ways that you actually use parentheses

05:22 while you're doing your Python syntax and what you can use it for.

05:24 So, you get a couple of the simple topics like, you know, usually a parentheses is used in a callable,

05:31 like to call a function and pass in parameters or to call a class that implements callable.

05:36 Things like prioritization of operations or conditionals.

05:42 You also use parentheses for making tuples.

05:44 But you'll also get a little bit into generator expressions and the advantages of that.

05:50 And a couple of little quirks you can use it for securing some of the indentation rules that Python has that some people kind of hate.

05:57 But other people like me love.

06:00 So, I'm special.

06:01 You also get into square brackets and curly braces.

06:04 And square brackets, which are typically used for lists and for indexing.

06:10 For somebody that's new to the topic, you'll want to look at the slices section.

06:15 Because slices are a pretty powerful little tool that you get out of Python.

06:20 If you haven't used it before, how to get specific sections of a list or iterable.

06:27 And there's also, while not in the article itself, but some of the folks that commented on the article also mentioned that some of the new type hint stuff also uses square brackets for identifying,

06:40 like the variables, like the variables, like the data type of floats, the data type that it's implementing.

06:50 So, if you have a list of floats, you would say list curly bracket floats when you're specifying what type it is.

06:55 Yeah, that's really interesting.

06:56 It's almost like generics in like C# or templates in C++ where you would say this thing takes a list of strings.

07:06 You can say it's just a list.

07:07 But then, like, you don't get any help on what's contained within it.

07:10 But you could say, you know, import the list thing and say list square bracket int square bracket.

07:15 Then it has to be a homogeneous list of ends, not just any random list, which is pretty cool.

07:19 Exactly.

07:19 I was looking through here, and down at the bottom, they're talking about some of the ways to, like, future-proof your code.

07:26 So, like, you can say from Dunder future import division.

07:31 And there's a proposal for braces, huh?

07:35 Uh-huh.

07:36 If you have a Python REPL open right now and you kind of want to try that, you'll get a neat little message of what the future will look like if you ever actually import braces.

07:47 Right.

07:47 So, if you can see, like, the coming braces feature, you can say from Dunder future import braces and see what support Python's probably going to be adding for braces soon.

07:56 Which, you know, not everyone's typing.

07:59 They're probably driving this up.

08:00 So, basically, it throws a syntax exception error and says not a chance.

08:06 We're never adding braces.

08:07 It's beautiful.

08:09 I knew about anti-gravity.

08:11 We were joking about that earlier.

08:12 But I did know about the import braces.

08:13 That's pretty sweet.

08:14 One more interesting thing to mention, obviously, goes into curly braces and how you use that as well for set comprehensions and dictionaries.

08:21 The other thing to remind folks is Python 3.6+.

08:24 There is f-strings.

08:25 And with f-strings, you can use braces inside a string that you prefix with f.

08:33 And the interpreter replaces any code that you put inside those braces, actually executes it, and replaces the result into the string.

08:41 Yeah.

08:42 Very nice.

08:42 f-strings are great.

08:43 And it's way more efficient.

08:44 Fastest and the shortest.

08:46 Cleanest.

08:46 Very nice.

08:47 So, Brian, you mentioned that Mew Editor is a Qt application.

08:52 And Qt is kind of making a bit of a resurgence these days.

08:55 At least I've been paying more attention to it.

08:57 Yeah.

08:57 Yeah.

08:58 Well, it had gone through some fairly dark times.

09:00 I mean, obviously, we've been on our GUI kick for a while.

09:03 We're going through all these different options.

09:04 And there's still tons of great options.

09:06 Like, WX Python had their Phoenix release, which was sort of a rebuilding of that whole thing, which is awesome.

09:12 A little while ago, we talked about that.

09:14 So, the Qt company, Qt company, is the company that is behind the Qt framework.

09:20 And they just announced the official release for Python for Qt, which is taking these various version mismatch, PySide 2, PyQt, all those things, and, like, rebuilding it, like, on a two-year project into a fresh, new, shiny version.

09:36 So, that's pretty awesome that that's more or less out.

09:38 Oh, that's exciting.

09:39 We heard recent, not too long ago, that it was coming.

09:42 But having it be released, wonderful.

09:45 Yeah.

09:45 So, if you're messing with this, it's version 5.11.

09:47 And I think it's still in a tech preview in terms of the execution bits.

09:53 But I suspect that this means the APIs are frozen.

09:56 So, you can go and check that out.

09:57 Yeah.

09:58 So, it started two years ago.

10:00 They've been working on this.

10:01 And one thing that's really nice is the way you get it is you just pip install.

10:05 And right now, it's not coming out of PyPI.org itself.

10:10 It's coming out of a different place.

10:11 So, they show you the command, like, to pass their particular sort of dev, their dev index URL, which I put in the show notes.

10:19 So, people can check that out.

10:20 So, that looks like they have their own PyPI implementation there.

10:24 Yeah.

10:24 Something like that, right?

10:25 Like, a little bit like what you guys are doing that we talked about over on Talk Python, right, Chris?

10:29 Yep.

10:29 Exactly.

10:30 But this one goes outside the firewall, it looks like.

10:32 Nice.

10:34 So, you know, I just want to give a shout out.

10:35 People who are looking, waiting for Qt to become more important to get revitalized.

10:41 I feel like, you know, this is the announcement we've been waiting for.

10:44 Hopefully, this means lots of good things.

10:47 We'll see what happens.

10:47 Yeah.

10:48 Pretty cool.

10:49 Yeah.

10:49 For sure.

10:49 So, speaking of good things, DigitalOcean, they're very good.

10:52 They do all sorts of awesome stuff, right?

10:54 They're giving you guys tons of credit if you want to get started there.

10:57 And I always try to talk about different ways we are using them in our various bits of infrastructure.

11:02 And that's still true.

11:03 Still are.

11:04 Still enjoying that.

11:05 But one of the things that they have that's really cool is when you go create a virtual machine, you can say, I want a one-click app, which really means a virtual machine configured to run something.

11:14 And they recently set up a machine learning virtual machine for you.

11:18 So, you can go there, create a droplet.

11:19 That's their VM terminology.

11:21 Click on one-click apps.

11:22 Pick machine learning in AI.

11:24 And you automatically get a machine with Python 3, R, Jupyter, Notebooks, SensorFlow, PyTorch, all that stuff.

11:31 And you can pick, like, a CPU-optimized CPU for your virtual machine.

11:36 All sorts of good stuff.

11:37 So, if you want to check that out, you can do it real quick and affordably.

11:41 Just play around with those tools, which is pretty awesome.

11:43 So, check them out over at pythonbytes.fm/digitalocean.

11:49 And like I said, if you go there and you're a new user, you'll get $100 credit, which is also pretty sweet.

11:55 So, Brian, iteration is a key element of Python, right?

11:59 Yeah, we often deal with lots of iteration and generators and iterators and all sorts of things.

12:05 Exactly.

12:06 We've got generators.

12:07 Like, the primary for loop is not for I equals zero, I plus plus, but it's for thing in collection.

12:13 It's beautiful, right?

12:14 But it goes even deeper.

12:15 Developing your own iterators and generators is a fun thing to learn about.

12:19 But I have to admit that I don't often do that very much.

12:23 And one of the things that I've – it's always been on my to-do list is to learn more about the iter tools module.

12:30 And I've not really ever explored it too much.

12:33 And real Python has a blog post called iter tools in Python 3 by example.

12:41 And I really enjoyed this.

12:43 It's a nice introduction as to what is the problem that iterators and generators are dealing with.

12:49 And then, like, for example, it starts off with just how does zip work to take two lists and create another list with, like, each element.

13:00 And then what if you need, like, not quite the same zip?

13:04 What if they're not the same length and things like that?

13:06 And some of the problems that can happen and why lazy evaluation is a good thing.

13:11 And actually, in the discussion, it used the time function, the time shell function.

13:16 I guess this is, like, a Unix-y kind of thing with a dash f, which I've never used before.

13:23 And that showed the memory used also.

13:25 Didn't know that was a thing.

13:27 Oh, that's cool.

13:27 But this example of using, like, a big example in the memory usage blew up to, like, huge.

13:34 And so just talk through, like, some of the different things that are in iter tools and why that helps you.

13:41 I pulled out a couple.

13:42 Like, a lot of these things, if you don't know they're there, you'll just come up with it on your own.

13:47 Like, doing combinatorial sets.

13:51 Those are already in there.

13:52 Coming up with permutations, you don't have to do, like, a random index.

13:57 You can just use their iterate, the ones that are built in.

14:01 I think that's a good example of, like, being fluent in Python versus being able to make the code work but not really deeply knowing it, right?

14:08 Like, if somebody said, hey, I want you to take this thing and generate, like, a set of permutations, all the permutations of, say, this word or whatever, right?

14:15 You might attempt to implement the fairly complicated algorithm.

14:18 Or you might just call iter tools, you know, permute sort of thing, right?

14:23 And then, boom, it's just there.

14:24 So there's so many things like that that are just, like, at your fingertips if you just import them.

14:28 Yeah.

14:28 I mean, a lot of people are smart enough to, like, if you come up with all the combinations, you can just have a nested for loop and figure out how to do that.

14:36 But you don't have to.

14:37 It's already there.

14:38 And one of the things I didn't know, there's some fun things like some fun uses of count and cycle.

14:44 I didn't know about cycle.

14:46 That's pretty cool.

14:47 It just kind of cycles through a set and then keeps giving you more of the same.

14:52 And the tutorial also talks about, in the tutorial, it's using the next function, which is for iterators.

15:00 You don't have to use them in a loop.

15:03 You can even just call the next function, which is kind of fun.

15:07 And then something that's iSliced.

15:10 I didn't know this was a thing.

15:11 So if you want to take a slice of a list or a slice of some other iterator, you can do that.

15:19 But if you want that to be an iterable also, this does it for you.

15:24 And so there's a whole bunch of goodies in here.

15:26 Yeah, one of my favorites is iSliced because, like Chris already said, slicing is awesome.

15:30 But if you try to do, say, slice on a generator, it'll just go fail.

15:35 Like, nope, we don't slice generators.

15:37 Well, you can iSliced them, and it works just fine.

15:39 It's beautiful, right?

15:40 So you sort of make things sliceable that otherwise would not be.

15:44 It's really great.

15:45 Yeah, so this is definitely a good read to beef up on the iter tools.

15:51 Yeah, I recommend everybody that writes any Python code to just go look at iter tools and all the things you can do.

15:57 There's lots of stuff online, and this is a good resource.

16:00 Every once in a while, every time there's an article that's something about iter tools, I always go just at least skim it.

16:07 Because there's always some little magic in there.

16:10 You're like, oh, I implemented that myself the other day.

16:12 Let me go delete that code and actually do something that's maintained by somebody that knows something more than that.

16:17 Yeah, and maybe even in C.

16:18 So it's a little faster, right?

16:20 Down in the internals.

16:21 Nice.

16:22 So speaking of sort of working with collections and iterables and things like that, Chris, I feel like your item dovetails really well in with this.

16:30 Right.

16:31 So the next item is about Python sets and set theory.

16:34 It's a nice, also kind of a primer on how sets work in Python, how you divide them, how you work with them, and just a tiny bit on set theory.

16:45 So you can build sets different ways.

16:48 The most common way is by calling the set function to build an empty set.

16:53 But you can also use curly braces, which we were talking about earlier, to have set comprehensions.

16:58 And it's a great way of, say, deduping items in a list.

17:03 So if you have a list of a bunch of integers or something like that, you can use the comprehension to iterate through the list and just grab the items that you care about, and you only get the unique items out of it.

17:15 The interesting part about sets as well is that they're all of one.

17:20 So when you're making a membership test, it's fast.

17:24 It's considerably faster than going through, say, a list where you have to iterate through the entire list to see if the item is in it.

17:30 Yeah, that's cool.

17:30 I definitely like the distinct aspect.

17:32 That's what I use a lot of sets for.

17:35 It's like, I have all these things.

17:36 There might be duplication.

17:37 I just want them one of each.

17:39 You know, if there's duplicate, just don't add it.

17:42 Right.

17:42 So you can just, like, you could even say set of some list and then, you know, just get that back as here's the distinct stuff in the list, which is great.

17:50 Also, for simplifying conditionals.

17:54 So you have the example, well, Python had the example, and the stuff you covered about parentheses of if item equals x or item equals y or item equals z or whatever.

18:05 Right.

18:05 Like that becomes like kind of a nasty multiline looking thing.

18:09 Maybe a more Pythonic way of you say if x is in, you know, curly set x, y, z.

18:14 Right.

18:14 You can do stuff like that.

18:16 It's always another point to keep in mind is sets are of immutable values.

18:22 So you can't put, like, say, a normal set inside of a set.

18:28 There's other value types and stuff like that.

18:32 You can't just, like, stick in a set.

18:33 Right.

18:33 So it has to be hashable, basically same as dictionary keys.

18:36 Yeah.

18:37 Yeah.

18:37 Right.

18:38 So it can't change.

18:39 But it's always, always interesting to remember once you've made a set that you're looking for distinct values and things like that.

18:45 I always try to look through my code if there's some sort of, if I'm checking if item is in list one and also in list two, because you can always have two sets and do an intersection between them.

18:56 And then you don't have to do those for loops.

18:59 And the code is kind of optimized to do that for you, which I'm sure will not be all of n squared when you're writing your code.

19:06 Right.

19:06 Yeah, exactly.

19:07 And then just to quickly look back on immutability, if you want to make a set of sets, there's also such a thing as a frozen set where the set itself is immutable.

19:17 And you can stick that into a set.

19:20 So stuff like that.

19:21 That's very meta.

19:22 Brian, do you use sets very often?

19:23 I always have, like, a tutorial like this or something to look up because I forget what the operators are.

19:29 Because it does have union, intersection, difference, symmetric difference, things like that.

19:35 And remembering all of that stuff from your college days is good to try to make some elegant code.

19:43 But it has, like, for instance, the union operator is you can just use the bar function for that.

19:49 And looking up all those is a good thing.

19:52 Although, since I know I have to look it up, I usually put a comment in there to tell anybody else what I'm doing to say this is a set operation going on here.

20:02 Yeah, it makes sense.

20:03 I feel like sometimes knowing the right data structure cannot, like, really open people's eyes or really change the way they're doing something.

20:11 And sets and dictionaries definitely seem to fall into that space where, like, you don't use them that much.

20:16 But when you do, you're like, whoa, that really is better.

20:18 So many ways.

20:20 Yeah, and it's also one of those things of, like, it's a new hammer.

20:23 Try to be sure that you don't see everything as a set problem.

20:28 Because everything isn't a set problem.

20:31 Yeah, for sure.

20:32 All right.

20:32 So last item that I wanted to cover on this episode is a little bit of a look ahead, maybe to next week.

20:39 But to put this on people's radar so when it launches, you can, like, do maybe a backflip or something if you've been practicing.

20:46 So coming up, we just had the release of Python 3.7 Release Candidate 1, which was on June 12th.

20:54 And expected or planned for June 27th, which is seven days from now, is the final release of Python 3.7 official.

21:02 How about that?

21:03 I'm so excited.

21:04 Do you know what makes me most excited about this?

21:05 There's certain things in here like, oh, okay, cool.

21:07 Breakpoint.

21:08 That's kind of nice.

21:09 Data classes, kind of nice.

21:11 But what really makes me most excited is this is the categorically fastest Python period.

21:17 So all the people that say, no, we're using legacy Python because under this particular use case, it's faster than Python 3.7.

21:25 And there may still be some very narrow use case.

21:27 But generally speaking, this is the fastest Python period.

21:30 It's much faster than Python 3, certainly up to 3.3.

21:36 But it's even quite a bit faster than 3.6.

21:38 So, for example, from 3.6 to 3.7, when you're calling methods, especially methods that are part of classes, not standalone functions, but, like, bound methods to classes, it's, like, 20% faster.

21:51 That's a reason right there to switch.

21:52 Yeah, and what's cool, like, all you got to do is just run on the new version, right?

21:55 There's no, like, oh, I switched to PyPy or something.

21:58 It's just I now have 3.7, so life is better.

22:01 Especially if you're using a framework.

22:02 Yeah.

22:03 Anybody that's using a framework, remember, there's a bunch of levels of abstraction around it.

22:07 So there's a bunch of function calls.

22:08 Exactly.

22:09 Yeah, there's tons of function calls.

22:11 And so this is really, really good news.

22:14 So just to run through some of the features, there's improvements to coupling that type annotations or type hints added to the system.

22:24 So previously, if I wanted to say, here's a function, and it returns this type of thing, right?

22:30 It returns, like, this object or some type I've defined.

22:33 I have to literally import that type at the top of that file.

22:36 And what that means is at import time, I pay an extra import processing that file, which I might not have otherwise loaded, potentially, or at least not right then.

22:47 The other one is circular dependencies are super annoying in that.

22:52 Like, so, for example, I've got, like, a repository class, and it returns some kind of object, right?

22:59 But that object, when it's defined, has to know about the repository.

23:01 So it says it returned, like, it uses this somewhere else.

23:04 Like, that basically will fail and break the import because it's circular, right?

23:10 So with this new thing, this change is instead of actually evaluating these type hints and having to import them, it's just evaluated as if you had typed them as strings.

23:21 So they're not actually evaluating the true types when you do type annotations.

23:25 So that gives you more flexibility.

23:27 The circular dependencies are a problem, and it's faster.

23:29 Yeah.

23:29 That's neat.

23:30 Yeah, the type annotations thing that makes me the most crazy is I have a class, and it's got, like, some function that returns an instance of itself.

23:38 You can't say that in the previous type hints as concrete types because you can't say the name of the class until it's fully defined.

23:45 But you're halfway through the class trying to say, this method returns one of me, you know?

23:49 You can get around it by putting quotes, but that's effectively, like, what this does without the syntax to put in the quotes.

23:56 So it looks more natural.

23:57 So you can do that now with the 3-side?

23:59 Yeah, but you have to put quotes, and you have to, like, say the name out exactly as a string.

24:03 Oh, okay.

24:04 Yeah, yeah.

24:04 Let's take a look at that.

24:06 Yeah, it's pretty cool.

24:07 All right, you also have data classes, which are really nice.

24:09 They're kind of like tuples.

24:11 They have a lot of interesting hashing and equality operators on them as well as representation ones.

24:17 They can be frozen, so they can be mutable or immutable, all sorts of things.

24:21 So kind of like enumeration, name tuple, tuple, it's stuff all brought together.

24:26 It's sort of a derivative of the adders project, but they decided not to move adders into the framework because it's evolving quickly, and they don't want to, like, freeze it.

24:35 So data classes, kind of the same thing.

24:37 I just want to point out that data classes has a back port for 3.6, so you can go ahead and start using those in 3.6 as long as you pip install them first.

24:45 Yeah, how do I get that?

24:46 pip install data classes?

24:47 pip install data classes.

24:49 Oh, that's pretty killer.

24:50 I didn't know about that.

24:51 All right, so there's a new breakpoint function, which we talked about.

24:55 We don't use that much because, like, if you just fire a PyCharm, who cares?

24:58 But there's some pretty interesting – it's got to be clicking the gutters.

25:03 But there's actually some pretty interesting ways to, like, say, hook a remote debugger to your code, things like that.

25:09 There's really interesting stuff going on there.

25:11 AsyncIO got better.

25:12 Chris, you should be happy about that.

25:13 Did you see these?

25:14 Some of this is pretty cool.

25:15 Tell me about it.

25:16 This asyncIO run function is a way of running a coroutine from synchronous code, which, I mean, that existed before, but you had to do, like, 50 million things to set your stuff up correctly and make sure you didn't break other –

25:28 You just call run, and it will internally, like, create the loop and do it for you?

25:31 Yep.

25:32 Just call run, starts coroutine.

25:34 Oh, that is sweet.

25:35 It starts an event loop, runs your coroutine, and closes the event loop at the end.

25:40 So you're going to have to be careful when you use this.

25:42 This is pretty cool.

25:42 And there's some of the task management stuff that's also a little bit better.

25:48 So this is pretty cool.

25:49 I'll have to – maybe I'll write a post on this.

25:52 Yeah, that's awesome.

25:52 Yeah, definitely cool.

25:53 Another one that's really nice is the time module.

25:57 And a bunch of other functions, as well, have become more accurate, especially over long durations, and they've taken on nanosecond resolution.

26:05 So you can import time and say time – you just call time, and it will give you a floating point value of the number of seconds since the epoch, like 1970.

26:16 But this – you can also now in 3.7 say time underscore ns, and it will give you the nanoseconds as an integer.

26:23 And because it's an integer, not a float, that means there's no drift or anything in sort of the floating point operations.

26:30 It's like truly the nanoseconds, which is awesome.

26:32 Yep.

26:33 All right.

26:33 And finally, I just want to close out.

26:34 Give it like – what would Python Bytes show be without?

26:37 A shout-out to Anthony Shaw.

26:38 Right, Brian?

26:39 Yeah, he's been a part of the show a lot.

26:41 For sure.

26:42 So he actually did a brand-new course on Pluralsight called What's New in Python 3.7.

26:49 So I put a link to his course there as well.

26:51 And actually, it's only about an hour long, but it goes really in-depth into like the advantages or all these various things.

26:56 So quite cool.

26:57 If that's easy for you to check out, go ahead and drop over there and check out Anthony's course.

27:02 Very nice.

27:03 Yeah, so I'm really excited for when this ships.

27:05 I think it's going to be great.

27:07 There always seems to be like some latency on the Linux distributions and stuff before I can really make use of it.

27:12 But, you know, pretty soon I'll be happy to be running this.

27:15 Yeah, definitely.

27:16 Yeah.

27:16 Do you guys have any extra news that you want to cover?

27:19 That's it for our official items.

27:20 I've been doing a lot of going back, went through all of the code that was in the pytest book to make sure it's 3.7 compatible,

27:29 which I was happy to find out that it's fine.

27:33 Nice.

27:33 So that's good.

27:34 Yeah, very cool.

27:35 I saw this really cool tutorial series about Mongo.

27:40 Do you know anything about this?

27:42 I may have spent an incredible amount of time working on this project.

27:45 Yeah, so I did a three-part, three-hour webcast series in partnership with Mongo.

27:50 And basically from concept to actually deploying it on DigitalOcean, actually, I rebuilt the PyPI.org website in MongoDB and then published it to the internet, which I then deleted.

28:05 So I don't have to pay to keep it running because there's a real one.

28:07 But yeah, there's like it's recorded.

28:09 People can go check it out.

28:10 You got the link in the show notes.

28:11 So that's awesome.

28:12 Yeah.

28:12 Nice.

28:13 It looks pretty fun.

28:14 Yeah.

28:14 Yeah.

28:14 Thanks for the shout-out.

28:15 Chris, anything you want to let people know about while you're here?

28:17 Nope.

28:17 I don't really have anything new.

28:18 Maybe just keep an eye out for a few new posts coming up and try to step past in my new blog.

28:25 Awesome.

28:26 Yeah.

28:27 There might be one about this asyncio.run, huh?

28:29 Yeah.

28:30 Awesome.

28:31 Yeah, you called it out.

28:32 You got to write it now.

28:33 So, yeah.

28:34 Remember, the internet is written in ink.

28:36 And so this is permanent now.

28:38 My next post was going to be about one of my modules, which uses asyncio a bunch.

28:44 So maybe I'm going to go back and experiment with 3.7 and what changes I would have to do there to write it up.

28:50 So this is pretty cool.

28:52 Yeah, awesome.

28:52 Well, Chris, thanks for being on the show.

28:54 And Brian, thank you as always.

28:55 Yeah, thank you.

28:56 Thanks for having me.

28:56 Thank you for listening to Python Bytes.

28:59 Follow the show on Twitter via at Python Bytes.

29:02 That's Python Bytes as in B-Y-T-E-S.

29:05 And get the full show notes at pythonbytes.fm.

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

29:12 We're always on the lookout for sharing something cool.

29:15 On behalf of myself and Brian Okken, this is Michael Kennedy.

29:18 Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page