You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I really enjoy using this package.
The functional approach is very attractive to me.
And in particular, I often use pipe and thread_(first|last).
Upon lot's of use I've made my own modifications and therefore would like to ask about it here to see if it's the philosophy of the package and perhaps I can try a pull request.
I should mention that I've never made a contribution to an external package, and therefore don't know about the real blows and whistles about such collaboration. So thank you for your comprehension.
The functions that I like are the following:
fromfunctoolsimportpartial, reducefromitertoolsimportchainVARHOLDER=Ellipsisclasspartialz(partial):
"""Allow Ellipsis (...) as variable holder."""def__call__(self, *args, **keywords):
args_i=iter(args)
args_0= (next(iargs) ifargisVARHOLDERelseargforarginself.args)
argz=chain(args_0, args_i)
keywordz= {**self.keywords, **keywords}
returnself.func(*argz, **keywordz)
defthread(val, *forms):
"""Unify thread_(first|last) to use Ellipsis placeholder."""eval_ff= (lambdavv, ff:
partial2(*ff)(vv) ifisinstance(ff, tuple) elseff(vv))
returnreduce(eval_ff, forms, val)
## This one is less important, but shows up in partialzdefinterweave(seq1, seq2, cond=None):
"""Replace elements of seq1 where cond is True with elements from seq2."""cond=condor (lambdaee: eeisNone) # return_none? seq_i=iter(seq2)
seq_0= (next(seq_i) ifcond(elem) elseelemforeleminseq1)
returnchain(seq_0, seq_i)
So the motivation for all of this was generalizing thread_(first|last) to having the arguments in any place, and that's how I came to find about something like partialz that use Ellipsis as placeholder for the variables.
And finally I was looking into ways to combine sequences based on the arguments argz in partialz, as the following line seemed to show room for simplification.
I really enjoy using this package.
The functional approach is very attractive to me.
And in particular, I often use
pipe
andthread_(first|last)
.Upon lot's of use I've made my own modifications and therefore would like to ask about it here to see if it's the philosophy of the package and perhaps I can try a pull request.
I should mention that I've never made a contribution to an external package, and therefore don't know about the real blows and whistles about such collaboration. So thank you for your comprehension.
The functions that I like are the following:
So the motivation for all of this was generalizing
thread_(first|last)
to having the arguments in any place, and that's how I came to find about something likepartialz
that useEllipsis
as placeholder for the variables.And finally I was looking into ways to combine sequences based on the arguments
argz
inpartialz
, as the following line seemed to show room for simplification.So my question is, Do these changes make sense in the project?
Thank you for reading me.
The text was updated successfully, but these errors were encountered: