Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created January 25, 2026 14:49
Show Gist options
  • Select an option

  • Save mypy-play/394d680facba8b792f1300b03a3c1b58 to your computer and use it in GitHub Desktop.

Select an option

Save mypy-play/394d680facba8b792f1300b03a3c1b58 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import reveal_type
import random
def choice[T](left: T, right: T) -> T:
if random.random() < 0.5:
return left
else:
return right
reveal_type(choice(3, "hey!"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment