check-in pyCode for safety
python code is approximately close