hauntsaninja / pyp

Easily run Python at the shell! Magical, but never mysterious.
MIT License
1.41k stars 39 forks source link

Consider first-level support of pipetools #8

Closed alendit closed 4 years ago

alendit commented 4 years ago

Pipetools (https://0101.github.io/pipetools/doc/pipeutils.html) is a nifty package which allows you to write code like this.

ls | pyp 'lines > pipetools.pipe | sorted | list'

While I wouldn't consider it for production use, it has incredible synergy with pyp. Being able to omit pipetools (like with math, etc) would make it even better.

Alternatively, a configurable list of default-imported modules in something like ~/.pyprc would be arguably even better.

rmcgibbo commented 4 years ago

Alternatively, a configurable list of default-imported modules in something like ~/.pyprc would be arguably even better.

In #5 and #6 we've been working on something like that. What do you think of the proposed syntax in https://github.com/hauntsaninja/pyp/pull/5#issuecomment-626389709?

alendit commented 4 years ago

Code-as-config for a tool like this would be amazing. I'll close it, as the other issues seem to cover this use-case.

dbieber commented 4 years ago

I checked out of curiosity and found the snippet in the original comment (ls | pyp 'lines > pipetools.pipe | sorted | list) can be simplified to just ls | pyp 'lines > pipetools.pipe | sorted, since pyp's default printing handles iterables in a natural way.

(And it can be simplified further to ls | pyp 'sorted(lines)' or even ls | sort, but those don't show off the pipetools package.)

alendit commented 4 years ago

Ah, printing iterables is very useful.

hauntsaninja commented 4 years ago

@alendit

Thanks for opening the issue! I just cut a release with an implementation of configuration, so pip install --upgrade pypyp and this should be possible! Here's the relevant section in the README: https://github.com/hauntsaninja/pyp#pyp-is-configurable Based on your feedback, I thought it would be good to mention pipetools, so thank you for that! Here's the complete changelog: https://github.com/hauntsaninja/pyp/blob/master/CHANGELOG.md#v03

Try it out and let me know if you have thoughts!