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
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/
2 comments
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
Guess I am confused though.. So string services are like string methods?? Methods aka Functions for strings ?
Answer 5272578c80ff334cf1000659
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 ‘ ‘
2 comments
Thank you so much for the explanation
Same here, thank for the great answers.
Popular free courses
- Free course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner Friendly4 Lessons - Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner Friendly11 Lessons - Free course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner Friendly6 Lessons