On Wed, Apr 22, 2015 at 5:45 PM, Guido van Rossum <guido at 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.Barker at noaa.gov -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150423/07e4f7fa/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4