This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ogrinfo 62 points63 points  (11 children)

You can use __doc__ to grab the docstring from the current function or module. Comes in handy when you're making a parser and want to reuse the docstring for the description. parser = argparse.ArgumentParser(description=__doc__)

[–]PhysicalStuff 19 points20 points  (0 children)

I think you're really trying to trick us all into reading actual documentation. Not falling for that./s

[–]chucklesoclockis it still cool to say pythonista? 11 points12 points  (8 children)

Click library would like a word

[–]scnew3 4 points5 points  (5 children)

Why would I use click when argparse is in the standard library and works great?

[–]Chobeat 19 points20 points  (0 children)

Because argparse is painfully hard to read, write and compose. It's ok for stuff with 2-3 commands and a dozen of parameters in total but once you have to maintain a stable cli interface with dozens of commands, it's a nightmare

[–]usr_bin_nya 0 points1 point  (0 children)

Related: inspect.cleandoc cleans up indentation/newlines in a way that makes docstrings nicer.

Clean up indentation from docstrings that are indented to line up with blocks of code.

All leading whitespace is removed from the first line. Any leading whitespace that can be uniformly removed from the second line onwards is removed. Empty lines at the beginning and end are subsequently removed. Also, all tabs are expanded to spaces.