Advertisement
here2share

# duck_typing.py

Feb 5th, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. # duck_typing.py
  2.  
  3. from io import StringIO
  4.  
  5. def write(message, stream):
  6.   stream.write(message)
  7.   stream.seek(0)
  8.  
  9. stream = StringIO()
  10. # file_ = open('/tmp/test.txt', 'w')
  11.  
  12. write(u'hello', stream)
  13. # write(u'hello', file_)
  14.  
  15. print(stream.read())
  16. # print(file_.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement