Ramashish Baranwal wrote: >> > I want a way to get the contents in the order of their declaration, >> > i.e. [B, A, D]. Does anyone know a way to get it? >> >> My suggestion would be to actually parse the text of the module. "Brute >> force" is what it's called ;). But doing so with, say, pyparsing >> shouldn't be *very* difficult.
> Nevertheless, it would be interesting to see how it can be done.:) >>> import pyclbr >>> classes = pyclbr.readmodule("mymodule") >>> sorted(classes, key=lambda name: classes[name].lineno) ['B', 'A', 'D'] Peter -- http://mail.python.org/mailman/listinfo/python-list