Created
March 5, 2020 22:56
-
-
Save akatrevorjay/696428bc4068de80a72a5137dec9924f to your computer and use it in GitHub Desktop.
ipdb run python module, aka the missing `ipdb -m`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Usage: $0 myapp.modulewithmain [ARGV..] | |
""" | |
import ipdb | |
import runpy | |
import sys | |
def main(): | |
mod_name = sys.argv.pop(1) | |
print(mod_name) | |
with ipdb.launch_ipdb_on_exception(): | |
ret = runpy.run_module(mod_name, {}, "__main__") | |
return ret | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment