Load modules conditionally Python
Regarding the safety aspect of your question.
The reason why exec() can be dangerous is that is can allow a nefarious agent to execute code that you never intended.
Let's assume for example that somewhere in your program, you have sensitive data elements such as:
username = secret_username
password = never_share

And let's also assume that someone calls your program like this:
mmain.py -p 'parser_class1;print globals()'

Then your exec() statement would actually be:
exec(&quot;import %s&quot; %('parser_class1;print globals()'))

And this would result in your program printing out all variables in your global space for them... including your username and password.
By making your program utilize the __import__ method as mentioned by @Jaime, you can at least prevent people from executing non-import statements in your code.
But, you should, whenever possible also examine the input from a user before using it to execute any dynamic code.