confused about the different built-in functions in Python

Cameron Simpson cs at zip.com.au
Sun May 25 22:36:58 EDT 2014


On 25May2014 15:55, Deb Wyatt <codemonkey at inbox.com> wrote:
>I am confused about how various built-in functions are called.  Some are
>called with dot notation
>
>each_item.isalpha()
>
>and some are called like 'normal'
>
>sum(numlist)
>
>How do you know/remember which way to call them?

Documentation.

However, some context:

each_item.isalpha() is not a builtin function as such. It is a method of the 
"str" class.

Whereas "sum" _is_ a builtin function, a globally known name which can be 
accessed and used without explicitly importing any module.

There's an explicit list of the builtin functions in the Python doco.

For a class, you can look at the doco for the class ("String methods" in the 
python doco, for the "str" class), or run:

   help(str)

at the interactive Python prompt.

Cheers,
Cameron Simpson <cs at zip.com.au>

Steinbach's Law: 2 is not equal to 3 -- even for large values of 2.



More information about the Python-list mailing list