Running the following code:
pdf = pdftotext.PDF(f,layout='raw')
produced this error:
'layout' is an invalid keyword argument for this function
Is there a way to list which arguments this, and any, function would take?
Running the following code:
pdf = pdftotext.PDF(f,layout='raw')
produced this error:
'layout' is an invalid keyword argument for this function
Is there a way to list which arguments this, and any, function would take?
Use the help built-in function of python.
help([object])
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.
Let's say you are coming from Python 2.7 and need help with the print
function of Python 3. Go to the interactive prompt and type help(print)
:
>>> help(print)
Help on built-in function print in module builtins: print(...) print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream. (END)
As you can see print
takes 4 keyword arguments (sep
, end
, file
, flush
). Press q
when you are done to exit.
help(f) shows documentation and parameters for a python construct f, like a class or function.
Eg on the console
help(print)
shows
Help on built-in function print in module builtins: print(...) print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream.
Help on my new function f ...
def f():
None
shows
Help on function f in module main:
f()
help
function in python can be used to view the documentation for a class or a function. I like to keep an IPython
interpreter running when coding in python. IPython
provides operators like ?
and ??
specifically for this purpose.