Hacker News new | ask | show | jobs
by acoderhasnoname 3635 days ago
the pythonic way of doing this is: https://docs.python.org/3/library/cmd.html
2 comments

Reading the sorce code for cmd gave me my first "I am enlightened" moment when first programming in Python.

"You mean I just add a do_functionname method and that gives me a functionname command in the shell? And I can understand the 'refection' code that does this, and it dosen't look like incredibly verbose black-magiv-voodoo? I'm sold"

There are some youtube talks about python metaprogramming that you might enjoy later on. Your colleagues a little less.
The python prompt toolkit is very nice too, providing a lot more modern functionality (eg syntax highlighting, mouse support, suggestions). http://python-prompt-toolkit.readthedocs.io/