Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # duck_typing.py
- from io import StringIO
- def write(message, stream):
- stream.write(message)
- stream.seek(0)
- stream = StringIO()
- # file_ = open('/tmp/test.txt', 'w')
- write(u'hello', stream)
- # write(u'hello', file_)
- print(stream.read())
- # print(file_.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement