In my module, I'd like to do something like
when defined(nre):
import nre
# code that works with regular expressions
so, if the user does
import nre
import my_module
then that code gets compiled, but if the user doesn't use nre, then we aren't going to uselessly import it or compile the related code in my_module.
Is something like that possible?
Araq, I think I can understand his intention:
He wants to use nre module only, if it is used by other foreign modules already. Maybe to not unnecessary blow total executable size or to not introduce more new dependencies. Maybe, he has the task to search for a substring, so when nre is used already, he will use a proc of nre, otherwise he may prefer using his own nre-free plain textsearch proc.