Hacker News new | ask | show | jobs
by civilized 1584 days ago
Could this be used without the "bp."? Half the point of coming up with a nicer notation is for the notation to actually be nicer.
2 comments

As pointed out, you could import _ directly into your namespace, or map it to some other shorthand name that doesn't interfere with your naming conventions.

Also note that the _ placeholder isn't the only way that better_partial helps you. You can also use ... to indicate that you want to omit all arguments except ones you explicitly pass as kwargs. For instance:

  from better_partial import partial, _

  @partial
  def f(a,b,c,d,e):
    return (a,b,c,d,e)
  
  f(_,_,3,_,_)(1,2,4,5) == f(..., c=3)(1,2,4,5)
Well, you could do

from better_partial import partial, _

presumably. Though since _ has some meaning in Python maybe you'd want to do

from better_partial import partial, _ as x

instead (or something like it).