Monday, May 8, 2023

What is Union in python?

Union here has nothing to do with C or the kind of unions found in C. It just means that you can provide either a str or a Path for the filename argument... whatever a Path is in this context.

Generally if you see a function you have no idea what arguments it takes, so the typing library (and syntax) gives you some possibilities to give some information there. If you want to say "give me either a string or a path, but nothing else" Union is the thing to do that. 

references:

https://stackoverflow.com/questions/40816798/how-to-provide-argument-as-union

No comments:

Post a Comment