-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: provide __dir__ method (and local context) for tab completion / remove ipython completers code #5050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Only provide 'public' methods | ||
""" | ||
ld = self._local_dir() | ||
return sorted([ d for d in dir(type(self)) if not d.startswith('_') ]) + ld |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need type(self)
, can just use self
also ipython provides control over completion of things starting with _
, maybe we should just do
ld = [c for c in self.info_axis if isinstance(c, compat.string_types) and compat.isidentifier(c)]
dir(self) + ld
because we still need to complete col names
not sure if info_axis
is public, doubt it....but u get the idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look in core/generic.py/_local_dir...that's exactly what I did (so that inheriterts can just override that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh duh.... 😪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm -1 on blocking users from introspecting private methods (like this
does). Makes it much harder to debug things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
easy enough.....I believe @cpcloud is right that ipython does that though (but the user can always call directly)
@jtratner done |
I want to look again but can't right now. |
Only provide 'public' methods | ||
""" | ||
ld = self._local_dir() | ||
return sorted(dir(type(self))) + ld |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd think this should be:
object.__dir__(self) + self._local_dir()
actually, aside from the one change I think we should make I'm fine with it. If you want to do sorted that's fine too. But it needs to be list(sorted, because sorted returns generator in python 3 |
not sure |
…remove ipython completers code (GH4501)
@cpcloud |
API: provide __dir__ method (and local context) for tab completion / remove ipython completers code
closes #4501
this removes the ipython completers code and instead defines
__dir__
,with a
_local_dir
that a class can overrideNDFrame objects will have a pre-defined local of the info_axis (e.g. columns in a DataFrame)
for example: