What's a call-tip to do?

T

Tal Einat

Hi all,

I just ran into this. In IDLE (Python 2.5), the call-tip for
itertools.count is:
"x.__init__(...) initializes x; see x.__class__.__doc__ for signature"

That's itertools.count.__init__.__doc__, while itertools.count.__doc__
is the informative doc-string ("DS" henceforth):
"""count([firstval]) --> count object

Return a count object whose .next() method returns consecutive
integers starting from zero or, if specified, from firstval."""


That seems very counter-intuitive to me - I would expect the DS for
__init__ to explain how to use the constructor.

IDLE's call-tip module obviously thinks so as it prefers the __init__
DS to the class's DS. IPython does the opposite as far as I can tell,
when I enter 'itertools.count?' it shows the class's DS, but shows
nothing for a custom class whose __init__ has a DS while the class
itself does not.

I'm wondering what a call-tip mechanism should do when a class and its
__init__ both have a DS. I'd be willing to work up a patch for IDLE's
call-tip module to work better in this regard, or for itertools and
similar classes in the stdlib, if needed.


- Tal Einat
reduce(lambda m,x:[m+s[-1] for i,s in enumerate(sorted(m))],
[[chr(154-ord(c)) for c in '.&-&,l.Z95193+179-']]*18)[3]
 
T

Terry Reedy

| Hi all,
|
| I just ran into this. In IDLE (Python 2.5), the call-tip for
| itertools.count is:
| "x.__init__(...) initializes x; see x.__class__.__doc__ for signature"
|
| That's itertools.count.__init__.__doc__, while itertools.count.__doc__
| is the informative doc-string ("DS" henceforth):
| """count([firstval]) --> count object
|
| Return a count object whose .next() method returns consecutive
| integers starting from zero or, if specified, from firstval."""
|
|
| That seems very counter-intuitive to me - I would expect the DS for
| __init__ to explain how to use the constructor.
|
| IDLE's call-tip module obviously thinks so as it prefers the __init__
| DS to the class's DS. IPython does the opposite as far as I can tell,
| when I enter 'itertools.count?' it shows the class's DS, but shows
| nothing for a custom class whose __init__ has a DS while the class
| itself does not.
|
| I'm wondering what a call-tip mechanism should do when a class and its
| __init__ both have a DS. I'd be willing to work up a patch for IDLE's
| call-tip module to work better in this regard, or for itertools and
| similar classes in the stdlib, if needed.

Perhap IDLE should be changed, but I am not sure. After more discussion
here, if any, this would be worth a tracker item.
 
R

Raymond Hettinger

I just ran into this. In IDLE (Python 2.5), the call-tip for
itertools.count is:
"x.__init__(...) initializes x; see x.__class__.__doc__ for signature"

My IDLE (1.2.2 running on Python 2.5.2) has the correct call-tip. I
don't know why yours is different. Also, help(itertools.count) does
the right thing.

Raymond
 
T

Terry Reedy

I just ran into this. In IDLE (Python 2.5), the call-tip for
itertools.count is:
"x.__init__(...) initializes x; see x.__class__.__doc__ for signature"

| My IDLE (1.2.2 running on Python 2.5.2) has the correct call-tip.

As does my 3.0 version. count([first_val]) -> count object
 
T

Tal Einat

Terry Reedy said:
Tal said:
I just ran into this. In IDLE (Python 2.5), the call-tip for
itertools.count is:
"x.__init__(...) initializes x; see x.__class__.__doc__ for signature"

| My IDLE (1.2.2 running on Python 2.5.2) has the correct call-tip.

As does my 3.0 version. count([first_val]) -> count object

Sorry, my bad. I'm working with an experimental version of
CallTips.py, and apparently it works differently... I should have
tested this before posting.


The problem still exists though; try the following, for example:

class A:
def __init__(self):
"Doc-string for the constructor"

The call-tip for A will be empty, instead of showing the constructor's
doc-string.

In my version, which prefers the __init__ doc-string to the class's
doc-string, the call-tip works for the above example but not for
itertools.count and such. It seems to me that preferring the __init__
doc-string should be the way to go... am I wrong?


- Tal Einat
reduce(lambda m,x:[m+s[-1] for i,s in enumerate(sorted(m))],
[[chr(154-ord(c)) for c in '.&-&,l.Z95193+179-']]*18)[3]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top