On 04/28, Chris Angelico wrote: > That's a lot of separate pieces. Here's the docstringargs equivalent: > > https://github.com/Rosuav/snippets/blob/dsa/snippets.py
Just for grins, here's that using Scription: -- 8< -------------------------------------------------------------------- """Store and retrieve snippets of text""" from scription import * import logging # Set the log output file, and the log level logging.basicConfig(filename="snippets.log", level=logging.DEBUG) data = {} @Script() def main(): print('Result: {!r}'.format(script_command())) @Command( name=('the name of the snippet', ), snippet=('the snippet text', ), ) def put(name, snippet): "Store a snippet with an associated name." logging.info("Storing({!r}, {!r})".format(name, snippet)) data[name] = snippet return name, snippet @Command( name=('the name of the snippet', ), ) def get(name): "Retrieve the snippet with a given name." logging.error("Retrieving({!r})".format(name)) return data.get(name) Main() -- 8< -------------------------------------------------------------------- and a sample run with nothing selected: -- 8< -------------------------------------------------------------------- $ python snippet Store and retrieve snippets of text snippet get NAME Retrieve the snippet with a given name. NAME the name of the snippet snippet put NAME SNIPPET Store a snippet with an associated name. NAME the name of the snippet SNIPPET the snippet text -- 8< -------------------------------------------------------------------- -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list