Created
January 26, 2013 19:46
-
-
Save bluele/4644140 to your computer and use it in GitHub Desktop.
sub-classing unicode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding:utf-8 -*- | |
__author__ = 'bluele' | |
class SubUnicode(unicode): | |
def __new__(cls, val, meta={}): | |
self = unicode.__new__(cls, val) | |
self.__meta = meta | |
return self | |
if __name__ == '__main__': | |
import unittest | |
class TestSimple(unittest.TestCase): | |
def setUp(self): | |
pass | |
def test_unicode(self): | |
self.assertEqual(SubUnicode('string'), unicode('string')) | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment