concept dot notation in category python

appears as: dot notation, The dot notation, dot notation
Get Programming: Learn to code with Python

This is an excerpt from Manning's book Get Programming: Learn to code with Python.

The next few operations that you can do on strings will take on a different look. You’ll use dot notation to make commands to the string objects. You have to use dot notation when the command you want was created to work on only a specific type of object. For example, a command to convert all letters in a string to uppercase was created to work with only a string object. It doesn’t make sense to use this command on a number, so this command uses dot notation on a string object.

  • Understand what dot notation means when working with objects
  • In lesson 7, you used dot notation on strings. Dot notation indicates that you’re accessing data or behaviors for a particular object type. When you use dot notation, you indicate to Python that you want to either run a particular operation on, or to access a particular property of, an object type. Python knows how to infer the object type on which this operation is being run because you use dot notation on an object. For example, when you created a list named L, you appended an item to the list with L.append(). The dot notation leads Python to look at the object, L, that the operation, append, is being applied to. Python knows that L is of type list and checks to make sure that the list object type has an operation named append defined.

    Figure 31.1. On the left are the data attributes of two circle objects. On the right, you can see that one data attribute changed after using dot notation on it to change the value.
    sitemap

    Unable to load book!

    The book could not be loaded.

    (try again in a couple of minutes)

    manning.com homepage
    test yourself with a liveTest