Mastering PyCharm Transcripts
Chapter: The Editor
Lecture: Viewing documentation

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Here we are back in this Wizard game
0:02 that we got came from the Jumpstart course,
0:05 we talked about where that comes from a few times.
0:07 Now, suppose I want to have a Hero attack a Creature,
0:11 so in our little world, a Hero is one of these Wizards,
0:14 the Creature, active Creature is a thing like a Small Animal
0:19 or a Dragon or another Evil Wizard things like this, right
0:22 this object hierarchy we just looked at in the previous video
0:26 it's one of those things.
0:28 Now, how do I know what to pass here?
0:31 Remember, I can take CMD or CTRL P
0:33 and it'll actually tell you what the arguments are.
0:36 Now in Python you always have this self-argument
0:38 but you never pass it on instant object
0:41 so self is a Wizard that's cool, here is a Wizard we know that.
0:44 But it says there's this Creature and Creature is just the name of the type.
0:49 However, look what else it's showing us,
0:51 it's showing us name and get defensive roll,
0:54 so Python has this concept of duck typing,
0:58 if it acts like a duck and walks like a duck— it is a duck.
1:00 Here what we're saying is we don't really care if it derives from Creature
1:03 as long as it has a name and a get defensive roll
1:06 that corresponds to how we plan to use it,
1:08 you can pass anything that kind of does that in here.
1:11 So this is really cool, so CTRL CMD P great.
1:14 Maybe there's some more help,
1:16 so we can come over here and we can view the quick documentation,
1:19 F1 on Mac bindings, we can go over here
1:22 it's the quick documentation, whatever that is,
1:25 so F1, in my example may be something else for you,
1:29 and it comes up and says here's the documentation for attack
1:32 it takes a self parameter again, you ignore that
1:34 that's like this in other languages,
1:37 and it takes a Creature and again, it says the same thing basically what we said,
1:41 it says here's the type, it looks like it takes this creature thing
1:45 and it returns a bool true or false right, and that's pretty standard.
1:49 But we could do better if there was actual documentation
1:51 for example, random.choice this is built-in, this has documentations
1:56 we pull that up it says ok well here's the deal
1:59 this is going to choose a random element from a non empty sequence
2:03 by the way, that's important, it's an exception
2:06 if the sequence is empty it has no elements,
2:09 but you can notice here it actually gives you the intellisense
2:13 or the documentation you're going to need
2:16 an links over to Python 3.6 implementation,
2:19 let's see another one over here and say format—
2:22 notice it takes all these things,
2:25 there's all these different ways in which you can use it
2:27 and it's going to return a formatted string
2:30 using the curly brace substitution like string format does.
2:33 Okay, so that's also really cool.
2:36 However, what if we want this, well, we'll see in a minute
2:40 that we can actually give this better documentation as well.