Wildemar Wildenburger wrote: > Peter Otten wrote: >> 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'] >> >> > > Good God! Is there *anything* that python does not already do? I hardly > feel the need to write programs anymore ...
+1 QOTW > Its really 80% like of the questions that are asked here get answered > along the lines of: > > import some_fancy_module > > solution = some_fancy_module.exactly_the_right_function_to_solve(problem) > > > > Kinda scary ... :) And you haven't seen the time machine working yet ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden ------------------ Asciimercial --------------------- Get on the web: Blog, lens and tag your way to fame!! holdenweb.blogspot.com squidoo.com/pythonology tagged items: del.icio.us/steve.holden/python All these services currently offer free registration! -------------- Thank You for Reading ---------------- -- http://mail.python.org/mailman/listinfo/python-list