On Mon, Feb 24, 2020, 9:27 AM Rhodri James <rho...@kynesim.co.uk> wrote:
> 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
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ETLFWIKGMB2626AVQV2VDLQCEKY7HP3H/ Code of Conduct: http://python.org/psf/codeofconduct/