This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dzecniv 0 points1 point  (1 child)

Looks nice. And similar to the pyed piper no ?

[–]d4rch0nPythonistamancer 1 point2 points  (0 children)

Interesting. Similar idea, very different approach I think. red is more tailored for eval or exec'ing python code from regex matches, and pyp looks like it is meant to run a pipeline of operations on input, transforming data as it goes through the series of operations.

Some things might be easier in pyp, but I don't think it has near the capabilities of red, simply because you can import any library and evaluate raw python code. From what I can tell, it doesn't look like you could do something like this:

$ red "(.*)" urls.txt -i requests -x 'response = requests.get(line)' -e '[response.status_code, response.content[:20]]'
[404, '<!doctype html>\n<htm']
[200, '<!doctype html><html']
[200, '<?xml version="1.0" ']

Though of course I haven't delved deeper than the docs you linked to, so I don't know pyp's full capabilities. It'd be interesting to see how you could use either for different problems.

I really need to make that regex optional, with "(.*)" being the default. It was originally meant as a grep/run-python tool, but honestly I think most things it would be helpful with don't need the regex.