On Wed, Apr 22, 2015 at 5:45 PM, Guido van Rossum <gu...@python.org> wrote:
> Given that even if Difference existed, and even if we had a predefined > type alias for Difference[Iterable[str], str], you' still have to remember > to mark up all those functions with that annotation. It almost sounds > simpler to just predefine this function: > > def make_string_list(a: Union[str, Iterable[str]]) -> Iterable[str]: > if isinstance(a, str): > return [a] > else: > return a > fair enough -- and I do indeed have that code in various places already. Somehow, I've always been uncomfortable with checking specifically for the str type -- guess I want everything to be fully duck-typable. But then I wouldn't be doing type hints, either, would I? -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com