Find in ipython3

Michael Torrie torriem at gmail.com
Thu Jun 4 15:09:06 EDT 2015


On 06/02/2015 10:13 AM, Cecil Westerhof wrote:
> I am thinking about using ipython3 instead of bash. When I want to
> find a file I can do the following:
>     !find ~ -iname '*python*.pdf'
> but is there a python way?

No more than there is a bash-native way of doing find.  Bash scripts use
a myriad of external, utility programs like find, cut, awk, sed, etc to
do heavy lifting.  The same things work just fine in iPython.  Why do
you need a "python way?"  Besides, Python isn't really a shell scripting
language, and ipython seems more like a hack to me.  Bash, Zsh, etc are
all better suited to actual shell scripting because their syntaxs
integrate the spawning external processes and building pipes in a nice
way (if you can call bash syntax nice).  That's not to say Python can't
be used for system programming. It certainly can.  And it can replace
perl easily at fast text processing.  Generator expressions are the
single most powerful tool in this.

Why not use Python for what it's good for and say pipe the results of
find into your python script?  Reinventing find poorly isn't going to
buy you anything.




More information about the Python-list mailing list