A question about Stack

Discussion in 'Python' started by trunggauuoi, Oct 5, 2003.

  1. trunggauuoi

    trunggauuoi Guest

    Hi,

    I'm trying to use stack to build a HTMLTree for my parser. There is a
    HTMLTreeNode class. Each time I encounter a tag or text, I need to create
    and initialize a HTMLTreeNode and put it in a htmltree and a stack. The
    stack is the list of objects (HTMLTreeNode objects). I want to retrieve the
    instance from the stack to use it to append some info to the instance.
    However, I can't append anything to the instace that I just got from the
    stack. Actually, if I print out the stack, it will look like this:

    [<parserExample.HTMLTreeNode instance at 0x00A87030>]
    [<parserExample.HTMLTreeNode instance at 0x00A87058>]

    If I try to add something to the instance I got, I will receive an error
    message saying that the instance has no attributes, which are actually in
    the instance when I added it to the stack.
    I have no idea how to deal with this.

    Any help would be greatly appreciated

    Many thanks

    Trung
    trunggauuoi, Oct 5, 2003
    #1
    1. Advertising

  2. trunggauuoi

    trunggauuoi Guest

    hi again.
    I got this figured out. Just a stupid mistake

    "trunggauuoi" <> wrote in message
    news:%cNfb.499812$cF.176544@rwcrnsc53...
    > Hi,
    >
    > I'm trying to use stack to build a HTMLTree for my parser. There is a
    > HTMLTreeNode class. Each time I encounter a tag or text, I need to create
    > and initialize a HTMLTreeNode and put it in a htmltree and a stack. The
    > stack is the list of objects (HTMLTreeNode objects). I want to retrieve

    the
    > instance from the stack to use it to append some info to the instance.
    > However, I can't append anything to the instace that I just got from the
    > stack. Actually, if I print out the stack, it will look like this:
    >
    > [<parserExample.HTMLTreeNode instance at 0x00A87030>]
    > [<parserExample.HTMLTreeNode instance at 0x00A87058>]
    >
    > If I try to add something to the instance I got, I will receive an error
    > message saying that the instance has no attributes, which are actually in
    > the instance when I added it to the stack.
    > I have no idea how to deal with this.
    >
    > Any help would be greatly appreciated
    >
    > Many thanks
    >
    > Trung
    >
    >
    >
    >
    trunggauuoi, Oct 5, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Surinder Singh
    Replies:
    1
    Views:
    1,172
    Richard Bos
    Dec 20, 2007
  2. Casey Hawthorne
    Replies:
    3
    Views:
    1,061
    Flash Gordon
    Nov 1, 2009
  3. Debajit Adhikary
    Replies:
    36
    Views:
    2,230
    Andre Kaufmann
    Feb 10, 2011
  4. Sam Roberts
    Replies:
    1
    Views:
    208
    Yukihiro Matsumoto
    Feb 11, 2005
  5. Kenneth McDonald

    Why stack overflow with such a small stack?

    Kenneth McDonald, Aug 30, 2007, in forum: Ruby
    Replies:
    7
    Views:
    242
    Kenneth McDonald
    Sep 1, 2007
Loading...

Share This Page