Python2and3

this replaces #2912 by @prattmic