0

I'm playing around with the robotparses library, and I'm trying out the example program from:

http://docs.python.org/library/robotparser.html

My code is currently-

import robotparser

def TestMain():

    #Check robots.txt

    rp = robotparser.RobotFileParser()
    rp.set_url("http://www.musi-cal.com/robots.txt")
    rp.read()
    rp.can_fetch("*", "http://www.musi-cal.com/cgi-bin/search?city=San+Francisco")

The problem I'm running into is that when I run the code it runs successfully, but doesn't return anything, anyone have any idea why?

Thanks

1
  • your function doesn't have a return statement, how are you calling it?
    – root
    Oct 3, 2012 at 14:38

1 Answer 1

2

The example you are refering to is for interactive use in the interpreter and not a standalone program. You can't produce anything meaningful just by adding a def statement. For your function to return something there has to be an return statement. And to use a function you have to call it.

Here's a python book that should explain how to construct functions and turn them into programs.

1
  • Right, thanks. New to Python, still making mistakes on the basics.
    – djcmm476
    Oct 3, 2012 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.