"Methods that use dot notation only work with strings."


#1

9 Dot notation 9/16

This is stated in lesson 9/16: “Methods that use dot notation only work with strings.”

Shouldn’t this be string objects can only call the string functions. This makes it sound like only string related methods can use dot notation.

Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output


#2

Methods are slightly different from functions
A method is essentially a function defined within a class
A string method is only available to a string object. And class methods are called with dot notation.
A function such as len will be available to most(don’t quote me here) data types.
There is special syntax for class methods that lets them use their own len method(if defined) instead of the len function.

You are absolutely correct that the wording is misleading a bit.
Just know why dot notation is being used (because it refers to a class method, not a standalone function)


#3

This is a typo in the lesson that seems to have just cropped up recently. Read it as len(), not .len().

Please be sure to submit a bug report mentioning this typo.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.