Is it possible to use glob.has_magic?

I have a bit of code where I would like to know if the path has shell templates that seem to be something that will be defined in a central location. I found that glob.has_magic () provides this (it's just a regular expression: '[*?[]' ). But this method is not listed in the __all__ module __all__ and is not displayed in pydoc.

Should I just copy this regex into my code? (I would rather not do this)

Is there any risk to remove this method in future versions of python, since it does not appear in the documentation?

+4
source share
1 answer

Personally, I would copy the regex. It's not like the definition of glob patterns will never change, forcing you to change it in your code. The fact that the method is not accessible outside of stdlib means that there are no promises that it will not change in the future. I would not worry about this CHANGE in the future (for the same reason as above: the definition of the globe template will not change), but I would be worried that it could be DELETED if the module implementation were reorganized, no longer required.

+2
source

Source: https://habr.com/ru/post/1434058/


All Articles