`If ` Q from newbie

Discussion in 'Python' started by Ian Pellew, Feb 20, 2004.

  1. Ian Pellew

    Ian Pellew Guest

    Hi all;

    As my starter into Python I have a small project using pullparser.py

    My problem is testing what is coming back from a def() in
    pullparser.py
    I bet this is me not understanding something in Python.

    I do
    …..
    tk = p.get_token()
    print tk
    ……

    and get:-
    1 Token('data', '\n \n\n', None)
    2 Token('comment', '#include virtual="/software/main/inc/warning.inc"
    ', None)
    3 Token('data', '\n\n', None)
    4 Token('startendtag', 'meta', [('name', 'DC.Rights'), ('content',
    'Copyright (c) 2004 by IBM Corporation')])
    5 Token('data', '\n', None)
    6 Token('startendtag', 'meta', [('name', 'Security'), ('content',
    'Public')])
    7 Token('data', '\n', None)
    8 Token('startendtag', 'meta', [('name', 'Robots'), ('content',
    'index,follow')])
    9 Token('data', '\n', None)
    Etc.

    I wanna
    "if (tk????? is None): continue"

    More generally, how do I know what is being returned from a def()?

    Pointers/Advice pls.

    Regards
    Ian
     
    Ian Pellew, Feb 20, 2004
    #1
    1. Advertisements

  2. Ian Pellew

    wes weston Guest

    Ian,
    It looks like the function call is returning a Token
    object and that the Token object has three fields? You need
    to go into the pullparser.py file and find out what "p" is -
    not shown in your example. When the type of p is known,
    find out out what p.get_token() is doing.
     
    wes weston, Feb 20, 2004
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.