#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    4
    Rep Power
    0

    functions with functions


    I am new at this....

    I have this plagarised/hacked script for the grinder:


    from net.grinder.script import Test
    from net.grinder.plugin.http import HTTPRequest
    from HTTPClient import NVPair

    log = grinder.logger.output

    def foo():
    import random
    number = random.randrange(1, 2000, 1)
    return number

    # We declare a default URL for the HTTPRequest.
    request = HTTPRequest(url = "http://host")

    def page1():
    request.GET('/app')
    request.GET('/app/j_security_check?j_password=test&j_username=test')
    request.GET('/app/adduser.do?UserName=JSmith_foo()&userPassword=JSmith')

    page1Test = Test(1, "First page").wrap(page1)

    class TestRunner:
    def __call__(self):
    page1Test()


    how do I get the output of the function foo() to form part of the definition of the function page1()

    ???
  2. #2
  3. No Profile Picture
    Hi, I'm Calvin
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    LosAngeles, SanDiego, Houston
    Posts
    50
    Rep Power
    12
    you should place your code within [ CODE ] and [/ CODE ] tags (without the spaces) because it's good practice; if you had more complicated code it'd be a lot harder to tell where a function definition ends, the way you have it posted (tabs and spaces are stripped)

    plagarism isn't a good thing... and it's got nothing to do with hacking

    if you call foo() from page1()... that should give you the return value, you might want to store that into a variable and call it a day.
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    I agree with CV, plagarism definalty into somthing.. you should be admitting to .

    class TestRunner:
    def __call__(self):
    page1Test()
    page1Test isnt a valid function, loose the parentasis at the end or this jut isn't gonna work

    Have fun,
    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo