1 ## Copyright (C) 2008-2012 Julian Schnidder
2 ## Copyright (C) 2012 Carnë Draug
4 ## This file is part of Octave.
6 ## Octave is free software; you can redistribute it and/or modify it
7 ## under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 3 of the License, or (at
9 ## your option) any later version.
11 ## Octave is distributed in the hope that it will be useful, but
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ## General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with Octave; see the file COPYING. If not, see
18 ## <http://www.gnu.org/licenses/>.
21 ## @deftypefn {Function File} {[@var{output}, @var{status}] =} python (@var{scriptfile})
22 ## @deftypefnx {Function File} {[@var{output}, @var{status}] =} python (@var{scriptfile}, @var{argument1}, @var{argument2}, @dots{})
23 ## Invoke python script @var{scriptfile} with possibly a list of
24 ## command line arguments.
25 ## Returns output in @var{output} and status
30 ## Author: Carnë Draug <carandraug+dev@gmail.com>
32 function [output, status] = python (scriptfile = "-c ''", varargin)
34 ## VARARGIN is intialized to {}(1x0) if no additional arguments are
35 ## supplied, so there is no need to check for it, or provide an
36 ## initial value in the argument list of the function definition.
38 if (ischar (scriptfile)
39 && ((nargin != 1 && iscellstr (varargin))
40 || (nargin == 1 && ! isempty (scriptfile))))
41 [status, output] = system (cstrcat ("python ", scriptfile,
42 sprintf (" %s", varargin{:})));
44 error ("python: invalid arguments");