Effective PyCharm (2021 edition) Transcripts
Chapter: The Editor
Lecture: Show tooltips, params, help, etc.
0:00 We've seen some ways that PyCharm helps us understand the code that we're working with
0:04 even without navigating to it or to the documentation.
0:08 For example, if I don't know what goes in to get details and I hit
0:11 cmd+ P or ctrl+ P on Windows and Linux it'll show oh it takes an episode id
0:15 Now one thing we didn't do before we could have done,
0:18 which have been nice. If we could have put a type,
0:20 we did our return type here,
0:21 we didn't do the inbound type so we could do an int there and then if
0:26 we come back and do this,
0:27 It will say oh here's an episode id variable and it's a parameter and it takes
0:32 an integer. Well that's pretty good.
0:34 But if we look it over like over here for example,
0:37 it more formalize things like for example this request get or response raised for status navigate
0:46 our view rather quick documentation takes a moment and then it shows you an insane number
0:51 of keyword arguments we could pass and then sends a get requests and it tells you
0:58 about them and so on and we can go and look at more details.
1:01 It also tells you the type of information about them that was the type that has
1:05 returned and so on. This is fantastic.
1:09 Right Wouldn't it be cool if our own code could have that.
1:12 Yes, yes, it would.
1:14 And if your code has documentation as in a python doc,
1:18 string, it would already have that.
1:20 So let's go back here and look at this again.
1:22 So if I say view documentation.
1:26 I do get the type information that we've added which is fantastic and it's navigable.
1:30 I could click on here and go to episode and see what that really is.
1:33 I don't know what details mean.
1:35 That's kind of weird. Wouldn't it be great if we could go over here and
1:39 see more. So we'll hold down command or navigate over there.
1:42 We want to create a doc string.
1:44 Doc strings in python are basically strings that are not assigned to anything there at the
1:49 top. And they start with triple quotes.
1:50 So 123 quotes, Notice It Auto Close The three.
1:55 Cool. We had enter however,
1:58 boom we do this right at the top notice that actually it says all right,
2:02 we're going to generate formal doc string information here for you.
2:05 So this this will return the episode details for the episode with episode id.
2:12 And this will be the idea of the episode as an int and here
2:19 this will be the episode details if found otherwise.
2:26 None. All right. That all looks pretty decent.
2:29 Let's go back here and as for the quick documentation again,
2:36 look at that as sweet as that.
2:38 So this will return the episode details for the.
2:40 Episode with id. Episode id
2:41 And it has the parameters,
2:43 the idea of the episode as int which is also represented up here and then the
2:49 episode details have found really really nice the way that the quick documentation allows you to
2:54 navigate. Not just the formal pieces,
2:56 like we could also do this for e tree.
2:59 Right, This is a built in thing.
3:03 Here's the documentation from the standard library and you can actually click on this to get
3:07 to it. We also saw that we get it for requests,
3:10 but if we write our own documentation,
3:12 we get it for our own libraries as well.
3:14 And we saw that just the triple quote enter.
3:17 Boom, it will generate that for us.