+python3 support with less side effect

Since a command is global, using script local variable will give less side effect. It also localize the implementation and does not clobber the user command space.