How to get the same result as python -m requests.certs inside a python script?

This might be a dumb question -

in the command line, python -m requests.cert gives result:

What is the right way to get the result inside python script?

#!/usr/bin/env python
import requets


The script above returns result:
<module ‘requests.certs’ from ‘/usr/lib/python2.7/dist-packages/requests/certs.pyc’>

not sure why it is like this. I would like to get /etc/pki/tls/certs/ca-bundle.crt

When you run at command-line

python -m

I treat it the same as:

  • If bar is a module (ie file “”)
    from foo import bar
  • If bar is a package (ie directory “bar/” with an “”)
    from import __main__

However, technically the module code is loaded and passed to an exec call

This means that “” / " " need to exist, and will be executed like a script. A common idiom is to have in this file:

def main():
    # parse command-line arguments
    # then run application

if __name__ == "__main__":

Further reading:

1 Like

Thanks. That explains it.