I have a bit of code where I’d like to know if a path has shell wildcards, which seems like something that would be defined in a central location. I’ve found that glob.has_magic() provides this (it’s just a regex: '[*?[]'). But this method is not listed in the module’s __all__ list, and does not appear in the pydoc.
Should I just copy this regex into my code? (I’d prefer not to)
Is there a risk of this method being removed in future versions of python, since it does not show up in the documentation?
Personally I would copy the regexp. It’s not like the definition of glob patterns will ever change, forcing you to change it in your code. The fact that the method is not made available externally by the stdlib means that there is no promise that it won’t change in the future. I wouldn’t worry about it CHANGING in the future (for the same reason as above: the definition of a glob pattern won’t change) but I would be worried that it might be REMOVED if the module’s implementation were refactored so that it was not required anymore.