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


Talk Python's Mastodon Michael Kennedy's Mastodon