Methodological Approach: Regarding parentheses


#1

This question has less to do with the specific lesson, and more about Python generally, but I’m sticking it here because it’s most clearly illustrated in this lesson.

In short, why is it that defining classes earlier in the lesson, we could call, e.g., panda.name, but later, we must call hippo.description() – i.e., with parentheses?

Thanks in advance.


#2

() is the call operator. You place it after a value to call that value. If you did not include the call operator, then you weren’t calling that value.

The values that you typically call are functions, but there are other callable values too, such as types. If you for example call str, then you will get '' (empty string)


#3

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