Last active
January 18, 2018 06:01
-
-
Save LordAmit/149ac3af847d72225c3585df5c91c25b 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 | |
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 = Union[A, B] | |
def a_function_(variable: my_shortcut_union_type): | |
print("provided is " + str(variable)) | |
a_function(A) # ERROR | |
a = A() | |
a_function(a) # OKAY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment