swaroopch / edn_format

EDN reader and writer implementation in Python, using PLY (lex, yacc)
https://swaroopch.com/2012/12/24/edn-format-python/
Other
131 stars 31 forks source link

Add a Char class #77

Closed bfontaine closed 3 years ago

bfontaine commented 3 years ago

This PR adds a Char class, in order to fix the last item of #31.

Char inherits from str, so this is backward compatible.

# both expressions are true
Char("c") == "c"
isinstance(Char("c"), str)

In fact, unless you explicitely test it with isinstance(c, Char), a Char is indistinguishable from a one-char str.