Closed alendit closed 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?
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.
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.)
Ah, printing iterables is very useful.
@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!
Pipetools (https://0101.github.io/pipetools/doc/pipeutils.html) is a nifty package which allows you to write code like this.
While I wouldn't consider it for production use, it has incredible synergy with pyp. Being able to omit
pipetools
(like withmath
, etc) would make it even better.Alternatively, a configurable list of default-imported modules in something like ~/.pyprc would be arguably even better.