Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't use Numpy but it sounds like they're describing *, ** operators.

    default_args = ('x', 'y', 'z')
    default_kwargs = {'p': 'p', 'q': 'q', 'r': 'r'}
    
    def printer(x, y, z, /, *, p, q, r):
     print(f'x={x} | y={y} | z={z} | p={p} | q={q} | r={r}')  
  
    printer(*default_args, **default_kwargs)  # x=x | y=y | z=z | p=p | q=q | r=r
EDIT: Formatting.


Yes but also that lacks most of the documentation so it's not great.

If you have multiple callables taking these parameters documenting them is awkward, by default help/pydoc and sphinx will tell you that the parameters are `default_args` and `default_kwargs`, but that's not actually true, those are just intended as shortcuts / helpers .




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: