How to read typical function documentation in Python?

Why

class multiprocessing.Pool([processes[,initializer[,initargs[,maxtasksperchild]]]]) 

contain all of these ]]]]?

I do not understand how to read this structure?

+4
source share
3 answers

Typically, the documentation [ something] reads as " somethingis optional." In this particular case, it also implies dependence and should be read as follows:

  • processes is optional, but if you use it, you can also use:
  • initializer, which is optional, but if you use it, you can also use:
  • initargswhich is optional, but ... etc.
+3
source

", ([]) ( , )"

. http://docs.python.org/2/reference/introduction.html#notation

[processes[,initializer[,initargs[,maxtasksperchild]]]] , , initializer , initializer, processes . , .

, ( !):

Pool() 
Pool(processes) 
Pool(processes, initializer) 
Pool(processes, initializer, initargs) 
Pool(processes, initializer, initargs, maxtasksperchild) 

, , . :

Pool(processes=None, initializer=None, initargs=(), maxtasksperchild=None)

. (https://bitbucket.org/pypy/pypy/src/9d88b4875d6e/lib-python/2.7/multiprocessing/pool.py)

: http://docs.python.org/3/tutorial/controlflow.html#keyword-arguments

+3

Use []means that a private parameter is optional and may be omitted.

+2
source

Source: https://habr.com/ru/post/1526133/


All Articles