Yes, writing code that is compatible with different VTK versions is just as easy to do in Python as in C++. For example:
if vtk.VTK_MAJOR_VERSION <= 5:
threshold.SetInput(allSegmentsLabelmapNode.GetImageData())
else:
threshold.SetInputData(allSegmentsLabelmapNode.GetImageData())