direct writing for python 3