Profile image of felice_denigris
Submitted by felice_denigris
over 11 years

I can't find .join function on http://docs.python.org/

I am looking for a library of built in functions for Python. In this excercise we use .join() function. I wanted to further examine what it does by looking up the documentation on docs.python.org but I can’t find it? Is there a reliable source where I can find all Python2.7 built in methods/functions?

Answer 5271560af10c60c7b700005f

2 votes

Permalink

string.join - so it’s in the document about string http://docs.python.org/2/library/string.html#string.join

if it was a built-in it would be join, not .join there’s always a name before the dot

and the built-ins are here: http://docs.python.org/2/library/functions.html

index of standard library: http://docs.python.org/2/library/index.html

and then there are 3rd party libraries, those docs are elsewhere

and this one is good to be aware about: http://www.python.org/dev/peps/pep-0008/

Profile image of ionatan
Submitted by ionatan
over 11 years

2 comments

Profile image of felice_denigris
Submitted by felice_denigris
over 11 years

Thank you!! I guess I was confused because in the exercise it states we’re going to use another built-in Python function: .join. If we type

Profile image of felice_denigris
Submitted by felice_denigris
over 11 years

Guess I am confused though.. So string services are like string methods?? Methods aka Functions for strings ?

Answer 5272578c80ff334cf1000659

2 votes

Permalink

oh. oops. what you wanted was str.join, not string.join.. wasn’t even aware they both existed until now >_< THIS is str.join!

there’s a module called string a module is just another .py file that is run when you use the import statement the module string contains a couple of functions and classes a string is an instance of one of those classes (str or unicode) those classes contain methods, methods are functions that are defined in classes

str is a class string is a module

str.join is a method of the value type str string.join is a function in the module string

some code to show the difference between those two:

string.join:

import string
string.join(['bob', 'peter'], ' ') # evaluates into 'bob peter'

^join is a function in the module string, that’s why string needs to be imported, if instead doing: from string import join then string. would not be necessary

str.join:

' '.join(['bob', 'peter']) # evaluates into 'bob peter'

^’ ‘ is an instance of str, str contains the method join which can be called on ‘ ‘

Profile image of ionatan
Submitted by ionatan
over 11 years

2 comments

Profile image of felice_denigris
Submitted by felice_denigris
over 11 years

Thank you so much for the explanation

Profile image of Mon_D.Li
Submitted by Mon_D.Li
over 11 years

Same here, thank for the great answers.