This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Felice DeNigris
over 10 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/

points
Submitted by Jonatan
over 10 years

2 comments

Felice DeNigris over 10 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

Felice DeNigris over 10 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 ‘ ‘

points
Submitted by Jonatan
over 10 years

2 comments

Felice DeNigris over 10 years

Thank you so much for the explanation

eMon D Rice about 10 years

Same here, thank for the great answers.