<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 22, 2015 at 5:45 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>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:<br><br></div><div>def make_string_list(a: Union[str, Iterable[str]]) -> Iterable[str]:<br></div><div> if isinstance(a, str):<br> return [a]<br></div><div> else:<br> return a<br></div></div></div></div></blockquote><div><br></div><div>fair enough -- and I do indeed have that code in various places already.</div><div><br></div><div>Somehow, I've always been uncomfortable with checking specifically for the str type -- guess I want everything to be fully duck-typable.</div><div><br></div><div>But then I wouldn't be doing type hints, either, would I?</div><div><br></div><div>-Chris</div></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>