;; Fu Jie Huang  9/2002

;; create your own tuple, and assign value to its element
;; tuple is a very important composite data structure
;; it can be used as the (only) argument of a function call

;; to emulate the python code: (with line number)
;;  1. x= (2,3,4)
;;  2. print x


(libload "python/python")
(Py_Initialize)
(setq pdict (PyDict_New))
(PyDict_SetItemString pdict "__builtins__" (PyEval_GetBuiltins))

;; the only thing new in this demo is how to create a tuple
;; the code is self-explaining...
(setq ptuple (PyTuple_New 3))
(PyTuple_SetItem  ptuple 0 (PyInt_FromLong 2))
(PyTuple_SetItem  ptuple 1 (PyInt_FromLong 3))
(PyTuple_SetItem  ptuple 2 (PyInt_FromLong 4))

;; plant this newly created tuple into the process context (dictionary)
(PyDict_SetItemString pdict "x" ptuple)

;; check result
(PyRun_String "print x" 257 pdict pdict)
(Py_DECREF pdict)