arguments - Additional processing of arugments for a function in Python -
In writing a small library, I need to sanitize input on all the arguments of the function shown below: Src = pipes Import import pipes DP copy (source, DST, ID_file = '/ path / to / key'): .quote (src) import = pipes.quote (dest):
import: Src = pipes.quote (src) Id_file = pipes.quote (id_file) subprocess.check_output ('scp -r -i% s% s% s'% (id_file, src, dest))
Argument through pipe rather than driving each one clearly. Question (), how can I do this more beautifully, and in any number of arguments (* Args and ** quad, if present)?
Most subsystem accepts a list of task arguments:
The subprocess.check_output (['scp', '-r', '-i', id_file, src, dest])
The quote is no longer necessary.
-r ',' -i '] call_args.extend (args) call_args.extend (for arg in the item for kwargs.items () arg in arg) subprocess.check_output (call_args) < P> Of course, with the quads, you never know in what order they will call. .
Comments
Post a Comment