Skip to content

Instantly share code, notes, and snippets.

@bluele
Created January 26, 2013 19:46
Show Gist options
  • Save bluele/4644140 to your computer and use it in GitHub Desktop.
Save bluele/4644140 to your computer and use it in GitHub Desktop.
sub-classing unicode
#-*- 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