geekgeek
(John Smith)
1
This might be a dumb question -
in the command line, python -m requests.cert gives result:
/etc/pki/tls/certs/ca-bundle.crt
What is the right way to get the result inside python script?
#!/usr/bin/env python
import requets
result=requests.cert
print(result)
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
EpicWink
(Laurie O)
2
When you run at command-line
python -m foo.bar
I treat it the same as:
However, technically the module code is loaded and passed to an exec
call
This means that “bar.py” / "__main__.py " 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__":
main()
Further reading:
1 Like
geekgeek
(John Smith)
3
Thanks. That explains it.