How to get dictionary of variables in the main module python

I have been trying to get a dictionary of the variables in __main**_** module as i am programing code in an external module I’ve tried __main_.__dict_ and it gave a attribute error. Is there any other way to do this?

Nm i got it to work for the one other person that needs to see it heres the code for it

dict_variables: dict[str, Any]={}

        import \__main_\_

        globallogging=dir(\__main_\_)

        for object in globallogging:

            value=getattr(\__main_\_, object)

            dict_variables\[object\]=value