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 c
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
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
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
http://mai
Finally, i decide to make this:
from metatag import MetaTag
from htmltools import TagHTML
class Structure(object):
class A(TagHTML):
pass
class B(TagHTML):
pass
def get(self):
__all__ = dir(self)
classes = filter(lambda k: type(getattr(self, k)) == typ
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,
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 cou
"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 suc
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.C
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
w
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 all
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 ? do
12 matches
Mail list logo