Skip to content

Instantly share code, notes, and snippets.

@akatrevorjay
Created March 5, 2020 22:56
Show Gist options
  • Save akatrevorjay/696428bc4068de80a72a5137dec9924f to your computer and use it in GitHub Desktop.
Save akatrevorjay/696428bc4068de80a72a5137dec9924f to your computer and use it in GitHub Desktop.
ipdb run python module, aka the missing `ipdb -m`
#!/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