diff --git a/Common/gmsh.i b/Common/gmsh.i
index bad364b2858c8983655ffc2a97266f293bbd77e4..d6a320814f14aa094538ee46d2975f679d9a3413 100644
--- a/Common/gmsh.i
+++ b/Common/gmsh.i
@@ -1,7 +1,14 @@
 %module gmsh
+
+// "int &outTag" in function arguments is replaced by an append of outTag to the
+// value returned by the function
 %include typemaps.i
-// reference to int is appended to the returned values of the function
 %apply int &OUTPUT { int &outTag };
+
+// handle gracefully the arguments of gmshInitialize
+%include argcargv.i
+%apply (int ARGC, char **ARGV) { (int argc, char **argv) }
+
 %{
   #include "gmsh.h"
 %}
diff --git a/demos/api/t1.py b/demos/api/t1.py
index c2493c71cea4e0c33fa9ab3564b559221fa4ac17..4fc14e9ae99c7cfab42b982b3dca2be12d0ec23e 100644
--- a/demos/api/t1.py
+++ b/demos/api/t1.py
@@ -50,7 +50,6 @@ gmshModelGeoAddLine(2, 3, 2);
 gmshModelGeoAddLine(3, 3, 4);
 gmshModelGeoAddLine(4, 4, 1);
 
-
 # The philosophy to construct line loops and surfaces is similar: the second
 # arguments are now vectors of integers.
 gmshModelGeoAddLineLoop(1, [4, 1, -2, 3]);
diff --git a/demos/api/t2.py b/demos/api/t2.py
index 5a4181126f246e4afd924eb7d615cf0d74557732..5360c9cfacfc195e88900c0f831f7dff505cb357 100644
--- a/demos/api/t2.py
+++ b/demos/api/t2.py
@@ -4,13 +4,17 @@
 # API functions used, compared to the ones introduced in t1.py.
 
 from gmsh import *
+import sys
+
+# If sys.argv is passed, Gmsh will parse the commandline in the same way as the
+# standalone Gmsh code.
+gmshInitialize(sys.argv);
 
-gmshInitialize();
 gmshOptionSetNumber("General.Terminal", 1);
 
 gmshModelCreate("t2");
 
-# Copied from t1.cpp...
+# Copied from t1.py...
 lc = 1e-2;
 gmshModelGeoAddPoint(1, 0, 0, 0, lc);
 gmshModelGeoAddPoint(2, .1, 0,  0, lc);