julia> function pval(val)
println("Value is ",val)
end
pval (generic function with 1 method)
julia> pval(1.0)
Value is 1.00000e+00
julia> pval("hello")
Value is hello
It seemed to me the quesion was partiularly about usage in a Jupyter notebook - that said, what you suggest is of course perfectly fine in that context as well:
Yup, Tested it in a notebook while you were writing your response. @ZettEff, remember to run the code cell which defines the function before calling the function.
Hm…this is what I tried, of course. It doesn’t work. Good to know it should work. Feel kind of like an idiot now and do understand why I could not find anything googling the issue…
I will inspect why my case is different (i.e. what I have done wrong…).
What’s unfortunately easy to do is to edit a function and change its signature to be something less specific, and re-run the cell. This then doesn’t overwrite the old definition, I think that’s a common way to get surprising results, at least for me! Running methods(pval) should print out all currently defined methods.
In Python I like to use the debug flag you set the flag to true at runtime. You do not then need to clean up your code and comment out the printlns
For example if __debug__: print variablename
__debug__
This constant is true if Python was not started with an -O option. See also the assert statement.