Re: [Tutor] listing classes

2008-05-22 Thread Kent Johnson
On Wed, May 21, 2008 at 10:41 PM, Laureano Arcanio [EMAIL PROTECTED] wrote: The problem comes because i need to keep the order of the HTML tags, and as you say dict doesn't work like that.. I've working on this metaclass, and then extend list with it, but i have the same problem, the dct comes

Re: [Tutor] listing classes

2008-05-21 Thread Laureano Arcanio
well it's true, using list it's scalable too. But It's doesn't looks friendly to the user to write the document. Syntacticly looks nice to keep some of the original structure of the html ( I mind, put the thags inside the document, and so on ). I'll making some test this days to see what i get,

Re: [Tutor] listing classes

2008-05-21 Thread Laureano Arcanio
sorry this is not true: There is a think left, i can't jus compare this: if type(somethingA) == type(somthingB): I transform type() to a string and then compare them.. (like in the code below) Thanks ___ Tutor maillist - Tutor@python.org

Re: [Tutor] listing classes

2008-05-21 Thread Laureano Arcanio
I'm using the dir() function, but this give me an alphabetic ordered list, is there any way to do the same but getting an appearance ordered list ?. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] listing classes

2008-05-21 Thread Kent Johnson
On Wed, May 21, 2008 at 7:45 PM, Laureano Arcanio [EMAIL PROTECTED] wrote: I'm using the dir() function, but this give me an alphabetic ordered list, is there any way to do the same but getting an appearance ordered list ?. Not easily. Attributes are stored in a dict; dicts don't preserve

[Tutor] listing classes

2008-05-20 Thread Laureano Arcanio
Hi All, I need to have a listing of all classes defined inside a class body, something like this: class A(object): class B(object): pass class C(object): pass(object): and i need to get the classes to instantiate them.. something like this. classes =[A,B] Any ideas ?

Re: [Tutor] listing classes

2008-05-20 Thread Thomas Pani
Hi, dir(A) will essentially give you what you want (and a little more) If you're only interested in classes, you can do something like: import types [ name for name in dir(A) if type(eval('A.'+name)) == types.ClassType ] Thomas Laureano Arcanio wrote: Hi All, I need to have a listing of

Re: [Tutor] listing classes

2008-05-20 Thread python
Thomas, import types [ name for name in dir(A) if type(eval('A.'+name)) == types.ClassType ] The == types.ClassType doesn't seem to pick out the classes. Also, I think you should be returning eval( name ) vs. name so that the OP gets a list of objects vs. names? (My take on what the poster

Re: [Tutor] listing classes

2008-05-20 Thread Kent Johnson
On Tue, May 20, 2008 at 12:47 PM, Thomas Pani [EMAIL PROTECTED] wrote: Hi, dir(A) will essentially give you what you want (and a little more) If you're only interested in classes, you can do something like: import types [ name for name in dir(A) if type(eval('A.'+name)) == types.ClassType

Re: [Tutor] listing classes

2008-05-20 Thread Alan Gauld
Laureano Arcanio [EMAIL PROTECTED] wrote I need to have a listing of all classes defined inside a class body, something like this: class A(object): class B(object): pass class C(object): pass(object): Others have answered but I'm curious why you would want to have such a

Re: [Tutor] listing classes

2008-05-20 Thread Dave Kuhlman
On Tue, May 20, 2008 at 01:48:03PM -0400, Kent Johnson wrote: Note: types.ClassObj is the type of old-style classes. The OP used new-style classes which are of type type. Using type(A) for the comparison means it will work with either kind of classes as long as they are the same. You could