Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Handle variable name

Dear all,

I would like to pass a function as a parameter and also one of its variable. The simplest situation would just to evaluate a function f.

``` def test(f,myvar,myval): return f(myvar=myval)

f = x^2 print(test(f,x,3) ```

It returns x^2, but I would like 9. Of course I don't know a priori what would be the name of the variable and f may have several variables.

The long question is that I would like to define something that plot(f,(x,xmin,xmax)). Is there's a standard way to handle this triple (x,xmin,xmax) ? Is there's a web page for the source code for such functions to study the standard implementation?

Thanks a lot! Arnaud

Handle variable name

Dear all,

I would like to pass a function as a parameter and also one of its variable. The simplest situation would just to evaluate a function f.

``` def test(f,myvar,myval): return f(myvar=myval)

f = x^2 print(test(f,x,3) ```

It returns x^2, but I would like 9. Of course I don't know a priori what would be the name of the variable and f may have several variables.

The long question is that I would like to define something that plot(f,(x,xmin,xmax)). Is there's a standard way to handle this triple (x,xmin,xmax) ? Is there's a web page for the source code for such functions to study the standard implementation?

Thanks a lot! Arnaud

Handle variable name

Dear all,

I would like to pass a function as a parameter and also one of its variable. The simplest situation would just to evaluate a function f.

```

def test(f,myvar,myval):
    return f(myvar=myval)

f(myvar=myval)

f = x^2 print(test(f,x,3) ```

print(test(f,x,3)

It returns x^2, but I would like 9. Of course I don't know a priori what would be the name of the variable and f may have several variables.

The long question is that I would like to define something that plot(f,(x,xmin,xmax)). Is there's a standard way to handle this triple (x,xmin,xmax) ? Is there's a web page for the source code for such functions to study the standard implementation?

Thanks a lot! Arnaud

Handle variable name

Dear all,

I would like to pass a function as a parameter and also one of its variable. The simplest situation would just to evaluate a function f.

def test(f,myvar,myval):
    return f(myvar=myval)

f = x^2
print(test(f,x,3)

It returns x^2, but I would like 9. 9. Of course I don't know a priori what would be the name of the variable and f may have several variables.

The long question is that I would like to define something that plot(f,(x,xmin,xmax)). plot(f,(x,xmin,xmax)). Is there's a standard way to handle this triple (x,xmin,xmax) (x,xmin,xmax)? Is there's a web page for the source code for such functions to study the standard implementation?

Thanks a lot! Arnaud