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


        [SIC\]PYTHON PythonCommandLine

    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)

      - With a 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
            import sys
            for i in sys.argv:
              print i, type(i)
            SIC> PYTHON PI 'PI' 1.234
   <type 'str'>
            PI <type 'str'>
            3.1415926535898 <type 'str'>
            1.234 <type 'str'>

Gildas manager 2014-07-01