What does this "point" in Python mean?

5

What does this point mean between the variable var and index ?

Example:

 var = ['João','Pedro','André','Alice']
 var.index('André')

Is there a name?

    
asked by anonymous 21.04.2017 / 15:42

1 answer

10

This is the dot operator or point operator. It is the operator that gives access to members of the object contained in the variable. These members can be object variables or methods.

Then in this case var is a list object. A list has some methods, one of them is index() . Then you are accessing the index() method contained in the list class and it will be applied to the object contained in var .

If you've already seen how to create a method in the class, you know its first parameter should be self which is the parameter that will receive this object that is before the point.

var.index('André')

is the equivalent of writing a function like this:

index(var, 'André')
    
21.04.2017 / 15:47