Loading video player…

Surveying Examples

00:00 Single leading underscores for non-public objects in Python. First, let’s have a look at where we are exactly in the course. Looking back at our summary of relevant naming conventions, we are at the first row of this table.

00:15 So single leading underscores and names with single leading underscores indicate that the name is meant for internal use. It looks like we are using two terms here, internal and non-public.

00:29 How are they related? Well, they are really just two sides of the same coin. An object is internal within the containing class, the module or the package.

00:39 So that means within the module, for example, that it was written, it is internal within that module, but that means it’s non-public outside of that module.

00:49 So it will be non-public outside of the containing class, the module or the package.

00:55 Now, I think we’re going to need a few examples here to show you exactly what that means.

01:01 So here’s a table that is roughly representing the structure of a package. So on the left-hand side you have the package that is the highest level. The way to read this table is a package can have several modules and a module can have several objects like constants variables, functions, and classes.

01:20 And classes can have members such as attributes and methods.

01:25 And in the name column we have a number of examples, and then in the example column there are the examples that we will be looking at. So you will be looking at five examples and you can always come back to this table to get your bearings and to see how these examples are related.

01:42 For our first example, we will be looking at a constant _PI and a function _validate.

01:51 Right. Enough tables and theory for now. In the next video, you’ll get your hands dirty with your example number one. See you there.

Become a Member to join the conversation.