Mattsteel wrote: > Sadly (for me), you're right... then the only way to use doctest to > work both in 2.6 and 3.1 (without modifications between them) is > something like this: > > #!/usr/bin/env python > ''' >>>> str(concat('hello','world')) > 'hello world' > ''' > from __future__ import unicode_literals > def concat( first, second ): > return first + ' ' + second > if __name__ == "__main__": > import doctest > doctest.testmod() > > Is there any way to avoid using str(...) to protect the string? > M.
I think you can work around the problem. The following should pass in Python 2.6 and 3.1: ''' >>> concat('hello','world') == 'hello world' True ''' from __future__ import unicode_literals def concat( first, second ): return first + ' ' + second if __name__ == "__main__": import doctest doctest.testmod() Peter -- http://mail.python.org/mailman/listinfo/python-list