On 23/02/2020 18:33, Steve Jorgensen wrote:
> In many ways, a string is more useful to treat as a scalar than a collection, so drilling down into collections and ending up iterating individual characters as the leaves is often 1 step too far.
I think the key word here should be "sometimes". A lot of the time I do
treat strings as scalars (or more often, string.split() as a sequence of
scalars), but sometimes a string absolutely is a sequence of characters,
and I want to be able to treat it as such.
Both of these needs are straightforward to address with my suggested AtomicString.
def descend(obj, ...):
if something:
descend(AtomicString(s) for s in obj.split())
elif otherthing:
descend(AtomicString (c) for c in obj)
else:
# non-string stuff, e.g. lists