next up previous contents index
Next: QUIT Up: SIC Language Internal Help Previous: PAUSE   Contents   Index


PYTHON

        [SIC\]PYTHON
        [SIC\]PYTHON PythonCommandLine
        [SIC\]PYTHON PythonScript.py

    Any form of the PYTHON command starts the Python interpreter and  inter-
    communication  between  SIC and Python at first call. Subsequent call do
    not repeat this initialization step.

    Three main interaction schemes are available:
      - Without argument, the user is exposed to the PYTHON prompt.

      - With a Python command line as argument  (any  string  following  the
        command), the command is transparently executed and the user recover
        the SIC prompt. Arguments starting with a slash (/) should  be  pro-
        tected  by  double-quotes: this avoids SIC to interpret it as a com-
        mand option. Remember also that Python is  case  sensitive  and  the
        string should take care of this. For example:
            SIC> PYTHON print "Hello world!"
            Hello world!
            SIC> PYTHON def f(x): return x*x
            SIC> PYTHON print f(2)
            4
            SIC>

      -  With  a PythonScript.py as first argument (i.e. ending with ".py"),
        the Python script is executed and then  the  user  recover  the  SIC
        prompt.  Arguments following the script name can be recovered in the
        sys.argv Python list. These arguments are interpreted by SIC  before
        being sent to the script. For example:
            SIC> TYPE show_args.py
            import sys
            for i in sys.argv:
              print i, type(i)
            SIC>
            SIC> PYTHON show_args.py PI 'PI' 1.234
            showrgs.py <type 'str'>
            PI <type 'str'>
            3.1415926535898 <type 'str'>
            1.234 <type 'str'>
            SIC>


Gildas manager 2011-04-01