some code quality cleanup.

do to some report of static analysis tool, unused variable (mainly that)
a few function re-declarations, a python2 print statement...

cf https://www.codacy.com/public/bussonniermatthias/ipython/issues
The `var` declaration is function-scoped, not block scoped, so as long as it was declared in each branch of this if-statement, it works.  I think the nasty case that's avoided by lifting the declaration is doing something like:
```
if (cond1){
    var actual_value = expr;
} else if cond2 {
    # No `var` declaration here.
    actual_value = expr;
}
# Undefined behavior if we hit the cond2 branch.
do_stuff_with(actual_value);
```