News for hackers. Stuff that matters.
Re:More intuitive partial function application in Python by civilized on Sunday February 20, 2022 @08:33PM (#30411003)
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.
Re:More intuitive partial function application in Python by cgrimm1994 on Monday February 21, 2022 @09:01AM (#30415957)
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)
Re:More intuitive partial function application in Python by mrtranscendence on Sunday February 20, 2022 @09:17PM (#30411244)
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).