Upper vs upper()?


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:

Accidentally typed upper without the () and got this:

<built-in method upper of str object at 0x7fd088246618>

What does that mean? Is it an error? Send help

Strings and Console Output


lets break it down, built-in method, what could this mean? some programmer built some method which allows us to convert to uppercase, and he named the method upper, that is nice, that makes it easier to remember and the method name describes what the method is going to do. isn’t that convenient?

of str obj, so apparently this method belongs to string object. You know (hopefully) what strings are? and it seems, string is an object, whatever that means. We will leave that for now

so is it an error? No, its not. It might look complicated, but its not really.

so, it seems we can do more with methods and functions the calling them.

in fact, lets take a function, its a bit easier, lets say we have len(), we could do:

my_len = len
print my_len("hello world")

what do you think happens?

Exactly, we store the function len in a variable, this variable is now a function, which we can use to determine the length! :slight_smile:

congratulations, you just wrote your first function. In a bit, you will learn that besides built-in function, you can also write your own custom functions


Ooh okay, so the interpreter read my typo as a built in function, but wasn’t able to execute it?
What does the jumble of letters and numbers mean?


executing function always requires parentheses, because you didn’t include parentheses, it instead showed you information about the built-in function instead.

not very important at this point.


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