def __init__(self, filename, **keywords): BookWriter.__init__(self, filename, **keywords) if is_string(type(filename)): self.f = open(filename, 'w') else: self.f = filename self.filename = filename
def test_is_string(): if PY2: assert is_string(type(u'a')) == True else: assert is_string(type('a')) == True
def close(self): if is_string(type(self.filename)): self.f.close()