- below code is my valid requirement.
import numpy as np
a =np.array([1, 3, 0, 2], int)
b =np.array([5, 2, 1, 2], int)
print(f'{a > b = }')
a > b = array([False,  True, False, False])
- I wanna make inner function which have f-string style.
import numpy as np
a =np.array([1, 3, 0, 2], int)
b =np.array([5, 2, 1, 2], int)
def myprn(text):
    print(f'{text = }')
myprn(a > b)
- result is not my requirement
- I wanna print 'a > b' instead of 'text'
text = array([False,  True, False, False])
#^^^ how to fix this requirement?
     
            
=?a > bis evaluated and saved astextbefore it is used in the f-string. What to do really depends on your use case. As is, your function does nothing, so you might as well use the print line directly. If the function actually is more complex, you could add a second argument where you pass a descriptive string and print that.evalif you're actually going to use it. As mentioned in another comment, it would help if you gave context of what you're trying to do because solving it this way is not the best...