when executing f2py fib1.f -m fib2 -h fib1.pyf I get the following error File " ^ SyntaxError: invalid syntax
Question: I am using `Mac 10.9` and running `Python 2.7.8`. Currently I am trying to use
`f2py`. I follow the example in the guide and typed

    
    
    $ f2py -c fib1.f -m fib1
    

and I receive the following error

    
    
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/2.7/bin/f2py", line 3, in <module>
        import f2py2e
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/f2py2e/__init__.py", line 10, in <module>
        import f2py2e
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/f2py2e/f2py2e.py", line 26, in <module>
        import crackfortran
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/f2py2e/crackfortran.py", line 1586
        as=b['args']
    

I have tried as well the following command

    
    
    $ f2py -c --help-fcompiler
    

and I receive the as error as above. I hope someone can help me. Regards


Answer: `as` is a reserved keyword in Python 2.6+.

Therefore trying to assign to it like this

    
    
    as=b['args']
    

is a syntax error.

It's used in [exception
handling](https://docs.python.org/2/tutorial/errors.html#handling-exceptions)
and the [`with`
statement](https://docs.python.org/2/reference/compound_stmts.html#with)
(context managers).

In Python 2.5 you already get a deprecation warning if you're using it:

    
    
    >>> as='foo'
    <stdin>:1: Warning: 'as' will become a reserved keyword in Python 2.6
    

So that's some _really_ old code you're trying to run. You've basically got
two options:

  * Use Python 2.5 or 2.4 to run it
  * Or fix the code and replace the variable `as` with something else.

