Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How do I type hint a question that returns a zip object? #1279

Unanswered
branlabs asked this question in Q&A
Discussion options

I've got a function that takes an arbitrary amount of lists (or any iterables, for that matter) and sorts them as one. The code looks like this:
image
How can I accurately type hint the function output?

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

I did a Google search for this and found this StackOverflow post which has your exact code in it. (This explains why you pasted an image instead of the code as text.) That post has an accepted answer:

def sort_as_one(*args: T) -> typing.Iterator[T]:
 return zip(*sorted(zip(*args)))

Not to make this weird but you should just be up front if you're asking about code from a StackOverflow post. There's nothing wrong with doing that. Is there something else you wanted to ask about it?

You must be logged in to vote
1 reply
Comment options

It's the literal text content of the SO question as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /