Stream: helpdesk (published)

Topic: What's a good way to get a fully qualified type.


view this post on Zulip Timothy (Apr 05 2022 at 09:59):

I'm trying to turn a type into its fully qualified name, as a string. I was hoping this would work "$(t.name.module).$(t.name.name)", but while for say t=IO or t=DataFrame it works, in other case such as t=Dict it doesn't.

Is there a good general solution for this?

view this post on Zulip Michael Hatherly (Apr 05 2022 at 10:02):

"$(parentmodule(t)).$(nameof(t))" perhaps? Seems to at least cover Dict as well.

view this post on Zulip Sebastian Pfitzner (Apr 05 2022 at 10:03):

otherwise, Base.unwrap_unionall first

view this post on Zulip Timothy (Apr 05 2022 at 10:03):

That seems to work well, thanks! Are there any caveats I should be aware of with parentmodule / nameof ?


Last updated: Oct 02 2023 at 04:34 UTC