Skip to content

Conversation

tacaswell
Copy link
Contributor

Sub-classing collections.Mapping and providing a iter and len
methods (completely delegated to _parsed_data) makes NumpyDocString
behave as a dictionary with fixed keys.

Sub-classing `collections.Mapping` and providing a __iter__ and __len__
methods (completely delegated to _parsed_data) makes NumpyDocString
behave as a dictionary with fixed keys.
@rgommers
Copy link
Member

Can't hurt I'd think. Any specific benefits that this brings?

@tacaswell
Copy link
Contributor Author

Mostly discoverability/to play nice with interactive tools.

We are working on a project at my day-job to parse docstrings to auto-generate wrappers for higher-level tools (https://github.com/tacaswell/VTTools/blob/wrap_extension/vttools/scrape.py is the current state) and the first pass was using doc_string_obj._parsed_data[...] to get the data out rather than doc_string_object[...] mostly because it was not obvious that __getitem__ existed.

@rgommers
Copy link
Member

makes sense, thanks.

pv added a commit that referenced this pull request Feb 14, 2015
ENH : NumpyDocString subclass collections.Mapping
@pv pv merged commit 96a0fe3 into numpy:master Feb 14, 2015
@rgommers rgommers added this to the v0.6 milestone Jan 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants