I have a function that prints. How to get its output to string?
Note: I cant change the function code.
def f():
print('hello world')
# do something
assert x == 'hello world\n'
I need this because spark dataframe has method explain
that prints info about execution plan. But I need this info as string in my program.
>>> df.explain()
== Physical Plan ==
Scan ExistingRDD[age#0,name#1]