str() for Symbol
This commit is contained in:
parent
3153dc7c62
commit
b192313c94
|
@ -52,7 +52,7 @@ def merge2(a, b, merge_embedded=None):
|
||||||
...
|
...
|
||||||
ValueError: Cannot merge items
|
ValueError: Cannot merge items
|
||||||
>>> merge2(Record('a', [1, {'x': 2}]), Record('a', [1, {'y': 3}]))
|
>>> merge2(Record('a', [1, {'x': 2}]), Record('a', [1, {'y': 3}]))
|
||||||
a(1, {'x': 2, 'y': 3})
|
'a'(1, {'x': 2, 'y': 3})
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,10 @@ class Symbol(object):
|
||||||
#xyz
|
#xyz
|
||||||
>>> Symbol('xyz').name
|
>>> Symbol('xyz').name
|
||||||
'xyz'
|
'xyz'
|
||||||
|
>>> repr(Symbol('xyz'))
|
||||||
|
'#xyz'
|
||||||
|
>>> str(Symbol('xyz'))
|
||||||
|
'xyz'
|
||||||
>>> import preserves
|
>>> import preserves
|
||||||
>>> preserves.stringify(Symbol('xyz'))
|
>>> preserves.stringify(Symbol('xyz'))
|
||||||
'xyz'
|
'xyz'
|
||||||
|
@ -228,6 +232,9 @@ class Symbol(object):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '#' + self.name
|
return '#' + self.name
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
def __preserve_write_binary__(self, encoder):
|
def __preserve_write_binary__(self, encoder):
|
||||||
bs = self.name.encode('utf-8')
|
bs = self.name.encode('utf-8')
|
||||||
encoder.buffer.append(0xb3)
|
encoder.buffer.append(0xb3)
|
||||||
|
@ -289,7 +296,7 @@ class Record(object):
|
||||||
return self.__hash
|
return self.__hash
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return str(self.key) + '(' + ', '.join((repr(f) for f in self.fields)) + ')'
|
return repr(self.key) + '(' + ', '.join((repr(f) for f in self.fields)) + ')'
|
||||||
|
|
||||||
def __preserve_write_binary__(self, encoder):
|
def __preserve_write_binary__(self, encoder):
|
||||||
encoder.buffer.append(0xb4)
|
encoder.buffer.append(0xb4)
|
||||||
|
@ -432,7 +439,7 @@ class RecordConstructorInfo(object):
|
||||||
return self.__hash
|
return self.__hash
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return str(self.key) + '/' + str(self.arity)
|
return repr(self.key) + '/' + str(self.arity)
|
||||||
|
|
||||||
# Blub blub blub
|
# Blub blub blub
|
||||||
class ImmutableDict(dict):
|
class ImmutableDict(dict):
|
||||||
|
|
|
@ -2,7 +2,7 @@ from setuptools import setup
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="preserves",
|
name="preserves",
|
||||||
version="0.992.0",
|
version="0.992.1",
|
||||||
author="Tony Garnock-Jones",
|
author="Tony Garnock-Jones",
|
||||||
author_email="tonyg@leastfixedpoint.com",
|
author_email="tonyg@leastfixedpoint.com",
|
||||||
license="Apache Software License",
|
license="Apache Software License",
|
||||||
|
|
Loading…
Reference in New Issue