DeprecationWarning

asked 2020-06-22 18:21:31 +0200

Tony-64 gravatar image

See the question in the example below. What is the cause off the inconsistency with respect to generating the DeprecationWarning?

 def testing(fn):
    print(fn(1))
    return

expr=x
testing(expr) # Yields DeprecationWarning: Substitution using function-call syntax and unnamed arguments ...
print(expr(1)) # No deprecation warning here. Why?

fn(x)=x
testing(fn) # No deprecation warnings here either.
print(fn(1))
edit retag flag offensive close merge delete

Comments

Because in the second case fn is a function that knows its arguments, not a random expression

sage: parent(x)
Symbolic Ring
sage: fn(x)=x
sage: parent(fn)
Callable function ring with argument x
FrédéricC gravatar imageFrédéricC ( 2020-06-22 18:56:31 +0200 )edit
1

I understand about the second case. However, it is the first example that is puzzling me.

def testing(fn):
    print(fn(1))
    return

expr=x
testing(expr) # DeprecationWarning
print(expr(1)) # No DeprecationWarning
Tony-64 gravatar imageTony-64 ( 2020-06-22 20:24:57 +0200 )edit