[Python-ideas] Modify inspect.getmembers() to return object members in source code order

Nathaniel Smith njs at pobox.com
Mon Mar 16 01:13:05 CET 2015


Line number information is retained, so you could sort by that. In fact you
could do this without modifying inspect.getmembers...

-n
On Mar 15, 2015 5:09 PM, "Chris Angelico" <rosuav at gmail.com> wrote:

> On Mon, Mar 16, 2015 at 11:02 AM, Cem Karan <cfkaran2 at gmail.com> wrote:
> > I'd like to suggest that inspect.getmembers() be modified to return
> elements in the order they are defined in the source code rather than in
> alphabetical order.
> >
>
> I'm not sure that that's really possible, unless you also are
> proposing that OrderedDict be used internally instead of a regular
> dict for all namespaces. That information doesn't exist.
>
> > As an example, consider generating unit tests for code that really
> > should have had unit tests as the code was written, but didn't
>
> If I had to solve this problem, I'd parse the source code. Chances are
> your functions/methods follow a straight-forward layout, so you should
> be able to read them and parse them fairly easily.
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150315/cefe82d7/attachment.html>


More information about the Python-ideas mailing list