In ipython there is a magic %less
which enables the regular shell less
command. So we can use
less fname
or
%less fname
to see the content of fname. Even wonderful thing is that we can also use
cat fname | less
or
%cat fname | less
but NOT(!!!) cat fname | %less
or %cat fname | %less
.
in ipython as well!
Sadly I find that for the non-magic python functions, the output seems not able to be used together with pipe to less. For example, none of the below works.
print(os.environ.keys()) | %less
print(os.environ.keys()) | less
echo os.environ.keys() | %less
echo os.environ.keys() | less
os.environ.keys() | %less
os.environ.keys() | less
Is there way to resolve this?
Sorry I didn't search SO carefully since 2 similar questions are already answered.
PLUS: I would appreciate if someone tells the strange behaviours for the %
and non-%
magic version with the existence of "|".
I guess this is also answered, but it's hard for me to search with correct keywords.