3 ms·
Another handy trick is to use "-c" for executing the string as a command[0]. You can separate the commands by newlines or ";" if you're lazy (like me). This is
by PyWoody 2y ago
Another handy trick is to use "-c" for executing the string as a command[0]. You can separate the commands by newlines or ";" if you're lazy (like me).
This is really handy when you're moving around environments and you want to get the path or location for a module:
>>> python3 -c "import httpx; print(httpx.__path__)"
or
>>> python3 -c "import httpx; print(httpx.__file__)"
[0] https://docs.python.org/3/using/cmdline.html https://docs.python.org/3/using/cmdline.html
- rnewme 2y agoFound this one recently: If you have python and curl you can extract tag and its contents out of html file curl -s http://www.google.com/ | python3 -c 'import sys; s=sys.stdin.read(); e=""; print(s[s.find(e)+len(e):s.find("")])'
- anitil 2y agoYou can also call '__import__' as a function to save yourself a few characters worth of rsi >>> python3 -c "print(__import__('httpx').__path__)"