Skip to content

Possible to distinguish between Sequence[str]/Iterable[str] and str? #1965

Closed

Description

@jtatum

If a function expects an iterable of strings, is it possible to forbid passing in a string, since strings are iterable? Seems like there are many cases where this would be an error, but I don't see an obvious way to check 't','h','i','s'.

Activity

  1. changed the title [-]Possible to distinguish between Iterable[str] and str?[/-] [+]Possible to distinguish between Sequence[str]/Iterable[str] and str?[/+] on Jul 29, 2016
  2. gvanrossum commented on Jul 29, 2016

    @gvanrossum
    Member

    The PEP 484 type system currently can't express this, sorry. You'll have to start a discussion in the PEP 484 tracker: https://github.com/python/typing/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions