# HG changeset patch # User Paul Boddie # Date 1480283229 -3600 # Node ID a5ab50def31fb009de650d4d0b5b2632e9db0d54 # Parent c3ad549fbda3bc84265895175e768b2e039c800c Added a program representation for buffer instances. diff -r c3ad549fbda3 -r a5ab50def31f lib/__builtins__/buffer.py --- a/lib/__builtins__/buffer.py Sun Nov 27 22:41:48 2016 +0100 +++ b/lib/__builtins__/buffer.py Sun Nov 27 22:47:09 2016 +0100 @@ -21,7 +21,7 @@ from native import _list_init, _list_append, _list_concat, _buffer_str -class buffer(object): +class buffer: "A buffer, used to build strings." @@ -64,4 +64,10 @@ return _buffer_str(self) + def __repr__(self): + + "Return a program representation." + + return buffer(["buffer([", repr(str(self)), "])"]) + # vim: tabstop=4 expandtab shiftwidth=4 diff -r c3ad549fbda3 -r a5ab50def31f tests/buffer.py --- a/tests/buffer.py Sun Nov 27 22:41:48 2016 +0100 +++ b/tests/buffer.py Sun Nov 27 22:47:09 2016 +0100 @@ -3,10 +3,11 @@ b.append(" ") b.append("world") b.append("!") -print b +print b # Hello world! b = buffer(["Hello "]) -print b +print repr(b) # buffer(["Hello "]) + b2 = buffer(["world!"]) b.append(b2) -print b +print b # Hello world!