Issue
Using python how can I make this happen?
python_shell$> print myPhone.print_call_log() | grep 555
The only thing close that I've seen is using "ipython console", assigning output to a variable, and then using a .grep() function on that variable. This is not really what I'm after. I want pipes and grepping on anything in the output (including errors/info).
Solution
Python's interactive REPL doesn't have grep
, nor process pipelines, since it's not a Unix shell. You need to work with Python objects.
So, assuming the return value of myPhone.print_call_log
is a sequence:
call_log_entries = myPhone.print_call_log()
entries_containing_555 = [
entry for entry in call_log_entries
if "555" in entry]
Answered By - bignose
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.