0

I am trying to look through some code and don't know what the asterisk in the following code means.

def pylog(func=None, *, mode='cgen', path=WORKSPACE, backend='vhls', \
          board='ultra96', freq=None):

What does the lonely asterisk signify in a function definition when not followed by the name of an argument?

I can only find results for *foo.

wkoz
  • 1
  • 2
  • It's not actually a parameter, but rather a marker separating ordinary parameters from keyword-only parameters. – chepner Nov 22 '22 at 02:31

1 Answers1

0

This syntax forces arguments after the * to be called with their keyword names when someone calls the function/method.

Example:

# This is allowed
pylog(math.log, mode='cgen')

# This is *NOT* allowed
pylog(math.log, 'cgen')
Mike L
  • 327
  • 1
  • 7