fix error in python example

Fixes Issue #6917