*args and **kwargs

Smith smith at smith.com
Fri Sep 2 09:31:26 EDT 2016


Hello to all,
I'm trying to understand the concept of * args and ** kwarg with python3
But I can not understand why I returns the error message "SyntaxError: 
positional argument follows the keyword argument" when I insert values.

You can help me?

def start(data=None, *args, **kwargs):
     print('==== Arguments =======')
     print('data is: ', data)
     print('args is:', args)
     print('kwargs is:', kwargs)

In [22]: def start(data=None, *args, **kwargs):
     print('==== Arguments =======')
     print('data is: ', data)
     print('args is:', args)
     print('kwargs is:', kwargs)


In [23]: start(data="Fish",2,3,tox="tux")
   File "<ipython-input-23-eb9c3abb9941>", line 1
     start(data="Fish",2,3,tox="tux")
                      ^
SyntaxError: positional argument follows keyword argument

In [24]: start(data="Fish",tox="tux")
==== Arguments =======
data is:  Fish
args is: ()
kwargs is: {'tox': 'tux'}



More information about the Python-list mailing list