Last active
January 18, 2018 09:37
-
-
Save LordAmit/ac9dd309903421de6bb46eab43c6c0e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Union | |
from typing import Type | |
class A(): | |
a: int = 0 | |
b: int = 0 | |
class B(): | |
a: int = 0 | |
b: int = 0 | |
def a_function(variable: Union[A, B]): | |
print("class provided is " + str(variable)) | |
my_shortcut_union_type = Type[Union[A, B]] | |
def a_function_(variable: my_shortcut_union_type): | |
print("provided is " + str(variable)) | |
a_function_(A) # Okay | |
a = A() | |
a_function(a) # OKAY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment