A function to generate Python code out of Mathematica variables.
It's quite primitive: basically it only supports exporting of numbers and (arbitrarily nested) lists. All numbers (even regular integers) are exported as floats.

Author: Fernando Perez <Fernando.Perez@colorado.edu>

\(\(mvars2pyfile[symnames_List, fname_, precision_:  24] := 
        Module[
{k, sym, symname, snamestr, symCForm, 
            pysym, pyfile}, 
pyfile\  = \ 
            OpenWrite[fname]; 
 (*\ 
            Write\ python\ header . \ 
                Mathematica\ uses\ \*""\< ... \>""\ for\ multiline\ strings\ *) 
WriteString[
            pyfile, 
\*""\<\"\"\" *** FILE AUTO-GENERATED BY MATHEMATICA.  DO NOT EDIT!!! *** \"\"\"

from Numeric import array

\>""]; 
For[k = 1, 
            k ≤ 
              Length[symnames], \(k++\), 
symname = 
              Extract[Unevaluated[symnames], k, 
                Hold]; 
snamestr = 
              StringReplace[
                ToString[
                  symname], {"Hold[" -> "", "]" -> ""}]; 
sym = 
              SetPrecision[ReleaseHold[symname], 
                precision]; 
pysym = 
              ToString[sym, CForm]; 
 (*\ 
              Print["name: ", 
                symname]; 
Print["name2: ", 
                snamestr]; 
Print["sym:  ", 
                sym];\ *) 
 (*\ For\ lists, \ 
              CForm\ doesn' t\ cut\ it\ in\ python, \ 
              we\ need\ to\ change\ things\ a\ bit\ *) 
If[
              Head[sym] === 
                List, 
\(pysym = 
                  StringForm["array(`1`)", 
                    StringReplace[
                      pysym, {"List(" -> "[", ")" -> "]"}]];\)
]; 
WriteString[pyfile, 
              StringForm["`1` = `2`

", snamestr, 
                pysym]];
]; \  (*\ 
            End\ for\ loop\ *) 
Close[
            pyfile]; 
Print["Output saved in file: ", 
            fname];
]\  (*\ 
        End\ module\ *) ;\)\)
SetAttributes[mvars2pyfile, HoldFirst];

An example of mvars2pyfile usage

anint  =  4
afloat  =  3.2
alist  =  {1, 2, 3}
amatrix = {{1.0, 2}, {3, 4}}
mvars2pyfile[{anint, afloat, alist, 
        amatrix}, "mathematicatest.py"]

To use this from python, simply say 'import filename'.  The mathematica variables become available as filename.foo, filename.var, etc.