Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74070 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2014-07-07 12:58 +1000 |
| Last post | 2014-07-07 12:58 +1000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How do you use `help` when write your code Chris Angelico <rosuav@gmail.com> - 2014-07-07 12:58 +1000
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-07-07 12:58 +1000 |
| Subject | Re: How do you use `help` when write your code |
| Message-ID | <mailman.11569.1404701890.18130.python-list@python.org> |
On Mon, Jul 7, 2014 at 10:53 AM, Ben Finney <ben@benfinney.id.au> wrote:
> There are two common cases where ‘help(foo)’ is unable to help:
>
> * If ‘foo’ is a function written without using keyword-only args, but
> needing to have a bunch of keyword arguments, the signature will often
> be the uninformative ‘foo(*args, **kwargs)’. A docstring is crucial
> here, but it's too often wrong or absent.
>
> I look forward to more and more functions migrating to use
> keyword-only arguments for these cases, so the function signature can
> become much more informative in ‘help’.
Most common cause of this problem is when a function ought to have
functools.wraps but didn't.
if DEBUG:
debug = print
else:
@functools.wraps(print)
def debug(*a, **kw): pass
Without wraps(), the non-debug-mode version of debug() is completely unhelpful.
There's another issue with help(), and that's when it's used on a
large class - it's not that it's unhelpful, it's more that the useful
information gets lost in the spam of a pile of dunder functions. Check
out help(1) for instance.
ChrisA
Back to top | Article view | comp.lang.python
csiph-web