0
do you have to know all functions ?
I understand that you don't have to memorize code but how can you know all the functions and their uses from the module you imported. thanks for any answer you give.
6 Answers
+ 4
read the documentation for the module you imported, of course you don't have to know all the functions, that's why the search bars exists, just memorize the main ones that you'll use often.
+ 4
You can use the dir function to get a list of all functions and variables from a namespace:
dir(str) ---> list of string methods
dir(math) ---> list of math methods
You can use help to get documentation from certain functions or whole modules:
help(str)
help(math)
help("math")
help(math.sin)
But you don't need to know all the functions, you need to know what you need for your project and where you can find the solutions.
If you for example searched a function to remove a directory, you may know that os is a module offering useful methods for filehandling, import it and use the dir method:
import os
print(dir(os))
You get a big list, you can use some list filtering algorithms to make it easier to find, what you are possibly searching for.
You would eventually find a name "rmdir" which sounds a logical name for an directory removing method, let's use help to make sure it is what we searched for:
help("os.rmdir")
It says that rmdir does what we expected, and we got information about how to use the method.
+ 3
It is simple the more you practise the more they get into your brain just like typing and at least most compilers have autocomplete feature
+ 2
I highly appreciate your answers thanks
+ 2
Welcome
+ 1
Yes we have not a memorize to do that ,but with the time of use it and work with it more and more we can store it in our mind dynamicly.