[Python-Dev] _length_cue() (original) (raw)
Bengt Richter bokr at oz.net
Fri Feb 10 18:35:10 CET 2006
- Previous message: [Python-Dev] _length_cue()
- Next message: [Python-Dev] _length_cue()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 10 Feb 2006 14:33:08 +0100, Armin Rigo <arigo at tunes.org> wrote:
Hi Nick,
On Fri, Feb 10, 2006 at 11:21:52PM +1000, Nick Coghlan wrote: Do they really need anything more sophisticated than:
def repr(self): return "%s(%r)" % (type(self).name, self.subiter) (modulo changes in the format of arguments, naturally. This simple one would work for things like enumerate and reversed, though) My goal here is not primarily to help debugging, but to help playing around at the interactive command-line. Python's command-line should not be dismissed as "useless for real programmers"; I definitely use it all the time to try things out. It would be nicer if all these iterators I'm not familiar with would give me a hint about what they actually return, instead of:
itertools.count(17) count(17) # yes, thank you, not very helpful enumerate("spam") enumerate("spam") # with your proposed extension -- not better However, if this kind of goal is considered "not serious enough" for adding a private special method, then I'm fine with trying out a fishing approach. For enhancing interactive usage, how about putting the special info and smarts in help? Or even a specialized part of help, e.g.,
help.explain(itertools.count(17))
or maybe
help.explore(itertools.count(17))
leading to an interactive prompt putting handy cmdwords in a line to get easily to type, mro, non-underscore methods, attribute name list, etc.
E.g. I often find myself typing stuff like [x for x in dir(obj) if not x.startswith('')] or [k for k,v in type(obj).dict.items() if callable(v) and not k.startswith('')] that I would welcome being able to do easily with a specialized help.plaindir(obj) or help.plainmethods(obj) or help.mromethods(obj) etc.
Hm, now that I think of it, I guess I could do stuff like that in site.py, since
help.plaindir = lambda x: sorted([x for x in dir(x) if not x.startswith('_')]) help.plaindir(int) [] help.plaindir([]) ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
But some kind of standards would probably be nice for everyone if they like the general idea. I'll leave it to someone else as to whether and where a thread re help enhancements might be ok.
My .02USD ;-)
Regards, Bengt Richter
- Previous message: [Python-Dev] _length_cue()
- Next message: [Python-Dev] _length_cue()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]