FIX py3ing some print statements
State: closed

I just grepped where there was python 2 print statement. There are still some in vbench/scripts/ez_setup and sphinxext/src (as well as in the rst docs), but these are all all from the main codebase.

```
grep "print [^(]" . -r
```

I don't know how to deal with the `print >>buf, empty` etc. (or whether we need to, ~~I've only labelled~~ there's only the two of these).... ?

_I found one by trying to use py3 before building, where I got a `print e` syntax error._


Labels:

Comments:
`print >>buf, empty` writes `empty` to `buf` (sans newline iirc) so u can translate the call to 

``` python
buf.write(empty)
```

i'm not sure if `2to3` catches the `print >>buf, empty`...i've gotten these syntax errors before and i'm not sure why `2to3` doesn't convert them, probably better to just do what ur doing and replace them...

also there are quite a few of these

``` python
try:
    lotz_of_teh_codez
except Exception, e:
    moar_codez
```

which is a syntax error in py3, but somehow they never trigger errors...

I think p to. 3 conversion changes these around so they work
put a pdb right before - they code looks different

but for some reason the `print e` ones don't...but only on occasion...i haven't spent any time investigating. when i uninstalled pandas and then reinstalled (vagrant precise32 box python 3) it worked fine...

You'd think it would kick up a fuss immediately on looking at the file, rather than complain when it hits that line... weird.

I'll replace those two lines with `buf.write(empty)` for "completeness".

@hayd can u throw a context manager in there if there isn't one :)

@cpcloud If you really want to make everything python 3 compatible, try running 2to3 with the `-w` switch, it'll write everything in place. Then you can see _all_ the places that get changed. You could search for every instance of `except` in the files and commit them as a change :) When Armin Ronacher began porting Flask, Werkzeug and Jinja2, he decided to make the entire code base compatible with Python 3 _without_ the `2to3` tool (and skipped 3.0 and 3.1 compatibility altogether, because of unicode issues).

there's so much annoying crap surrounding the python 2/3 issue. there's also so much extra kludge just to keep things compatible with both versions. and then you have to deal with cases in which the 2to3 tool doesn't work. i wish everyone would just move to python 3 and stop talking about it so that folks could solve _real_ problems. of course most of science python people use 2.7 so that i unrealistic at the moment.

i think probably using function `print` and _not_ using the cryptic `'print >> file, thing_to_print_to_file'` (what are we trying to do here, emulate `cat`? ;) are reasonable conventions to adopt, i know i always forget about function print cuz i'm _so_ used to using it as a stmt...

@cpcloud updated with buf.write should be good to merge...

Aaargh the buf.write doesn't work in py3, think I should just drop that, it's clearly being tested anyway (so not needed) - will remove this last commit.

what doesn't work?

`buf.write(empty)` as a replacement for  `print >>buf, empty`

but the good news is this was working in python 3 before anyhow (since changing it made previously passing tests fail).