Examples: use print() function in "python" example
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 22 May 2023 14:40:49 +0200
changeset 3814 ab0afe798428
parent 3813 6f3e20690172
child 3815 56f08ab3a491
Examples: use print() function in "python" example
exemples/python/py_ext_0@py_ext/pyfile.xml
exemples/python/python@py_ext/pyfile.xml
--- a/exemples/python/py_ext_0@py_ext/pyfile.xml	Mon May 22 14:38:25 2023 +0200
+++ b/exemples/python/py_ext_0@py_ext/pyfile.xml	Mon May 22 14:40:49 2023 +0200
@@ -6,19 +6,19 @@
   </variables>
   <globals>
     <xhtml:p><![CDATA[
-print "All python PLC globals variables :", PLCGlobalsDesc
-print "Current extention name :", __ext_name__
+print("All python PLC globals variables :", PLCGlobalsDesc)
+print("Current extention name :", __ext_name__)
 
 def MyFunc(*args):
-    print args
+    print(args)
 
 def MyOtherFunc(*args):
-    print "other", args
+    print("other", args)
 
 def SomeChange(*args):
-    print "count",OnChange.SomeVarName.count
-    print "first",OnChange.SomeVarName.first
-    print "last",OnChange.SomeVarName.last
+    print("count",OnChange.SomeVarName.count)
+    print("first",OnChange.SomeVarName.first)
+    print("last",OnChange.SomeVarName.last)
 
 
 ]]></xhtml:p>
--- a/exemples/python/python@py_ext/pyfile.xml	Mon May 22 14:38:25 2023 +0200
+++ b/exemples/python/python@py_ext/pyfile.xml	Mon May 22 14:40:49 2023 +0200
@@ -15,12 +15,12 @@
     i = ctypes.c_int()
     if(Python_to_C_Call(arg, i)):
         res = i.value
-        print "toC:", arg, "from C:", res, "FBID:", FBID
+        print("toC:", arg, "from C:", res, "FBID:", FBID)
     else:
-        print "Failed Python_to_C_Call failed"
+        print("Failed Python_to_C_Call failed")
         res = None
-    print "Python read PLC global :",PLCGlobals.Test_Python_Var
-    print "Python read PLC global Grumpf :",PLCGlobals.Grumpf
+    print("Python read PLC global :",PLCGlobals.Test_Python_Var)
+    print("Python read PLC global Grumpf :",PLCGlobals.Grumpf)
     PLCGlobals.Second_Python_Var = 789
     sys.stdout.flush()
     return res
@@ -47,23 +47,23 @@
 global x, y
 x = 2
 y = 5
-print "py_runtime init:", x, ",", y
+print("py_runtime init:", x, ",", y)
 ]]></xhtml:p>
   </init>
   <cleanup>
     <xhtml:p><![CDATA[
-print "py_runtime cleanup"
+print("py_runtime cleanup")
 ]]></xhtml:p>
   </cleanup>
   <start>
     <xhtml:p><![CDATA[
 global x, y
-print "py_runtime start", x * x + y * y
+print("py_runtime start", x * x + y * y)
 ]]></xhtml:p>
   </start>
   <stop>
     <xhtml:p><![CDATA[
-print "py_runtime stop"
+print("py_runtime stop")
 ]]></xhtml:p>
   </stop>
 </PyFile>