> On 21 Oct 2016, at 15:10, Mark Adams <[email protected]> wrote:
> 
> petsc_gen_xdmf.py works fine on my Mac but I get this error on a Cray. It is 
> looking for "file" but I give it a file name. On my Mac I have pything 
> v2.7.11 and on the Cray I have Python 3.4.3 :: Anaconda 2.2.0 (64-bit).
> 
> Any ideas?
> 
> -rw-r--r-- 1 madams madams    206176 Oct 21 07:03 ex3.h5
> 07:04 nid00039  
> /global/u2/m/madams/petsc/src/dm/impls/picell/examples/tutorials$ 
> ${PETSC_DIR}/bin/petsc_gen_xdmf.py ex3.h5
> Traceback (most recent call last):
>   File "/global/homes/m/madams/petsc/bin/petsc_gen_xdmf.py", line 241, in 
> <module>
>     generateXdmf(f)
>   File "/global/homes/m/madams/petsc/bin/petsc_gen_xdmf.py", line 235, in 
> generateXdmf
>     Xdmf(xdmfFilename).write(hdfFilename, topoPath, numCells, numCorners, 
> cellDim, geomPath, numVertices, spaceDim, time, vfields, cfields)
>   File "/global/homes/m/madams/petsc/bin/petsc_gen_xdmf.py", line 187, in 
> write
>     with file(self.filename, 'w') as fp:
> NameError: name 'file' is not defined

file is removed in py3k.  You should use "open" in both cases.  On py2 the 
docstring says:

open(...)
    open(name[, mode[, buffering]]) -> file object
    
    Open a file using the file() type, returns a file object.  This is the
    preferred way to open a file.  See file.__doc__ for further information.


so write:

with open(self.filename, "w") as fp:
   ...


Lawrence

Reply via email to