Skip to main content
change from write to define
Source Link

Python: writingdefining a function inside of a function

I am trying to write a function that can writedefine functions.

I tried this:

def function_writer():
    print "I am a function writer"  

    def new_function():
        print "I am a new function"
             pass
    pass

function_writer()
new_function()

However, my debugger complains that new_function is not defined and so this obviously is not the way to do it.

Does anyone know how to do this?

Thanks.

Python: writing a function inside of a function

I am trying to write a function that can write functions.

I tried this:

def function_writer():
    print "I am a function writer"  

    def new_function():
        print "I am a new function"
             pass
    pass

function_writer()
new_function()

However, my debugger complains that new_function is not defined and so this obviously is not the way to do it.

Does anyone know how to do this?

Thanks.

Python: defining a function inside of a function

I am trying to write a function that can define functions.

I tried this:

def function_writer():
    print "I am a function writer"  

    def new_function():
        print "I am a new function"
             pass
    pass

function_writer()
new_function()

However, my debugger complains that new_function is not defined and so this obviously is not the way to do it.

Does anyone know how to do this?

Thanks.

Source Link

Python: writing a function inside of a function

I am trying to write a function that can write functions.

I tried this:

def function_writer():
    print "I am a function writer"  

    def new_function():
        print "I am a new function"
             pass
    pass

function_writer()
new_function()

However, my debugger complains that new_function is not defined and so this obviously is not the way to do it.

Does anyone know how to do this?

Thanks.