SyntaxError: positional argument follows keyword argument

Alexandre Brault abrault at mapgears.com
Fri Jun 7 14:48:46 EDT 2019


On 2019-06-07 2:43 p.m., Rich Shepard wrote:
> I understand positional and keyword arguments and the syntax for the
> ttk.Checkbutton as described on
> <https://www.tcl.tk/man/tcl/TkCmd/ttk_checkbutton.htm>.
>
> $ python3 geochem.py
>   File "geochem.py", line 60
>     ttk.Checkbutton(text='Censored?', variable=input_var),
>     ^
> SyntaxError: positional argument follows keyword argument
>
> I've provided only keyword arguments to the call to the ttk.Checkbutton
> widget and am not seeing the positional argument that follows. Please
> show
> me what I miss seeing here:
>
> self.inputs['nondetect'] = LabelInput(
>             self, 'Censored?',
>             #input_var = tk.BooleanVar(),
>             input_var = tk.IntVar,
>             ttk.Checkbutton(text='Censored?', variable=input_var),
> )
>
> It does not matter if the variable holding the checkbutton's state is an
> IntVar or a BooleanVar, the same syntax error is generated. Commenting
> out
> all widgets prior to this one makes no difference so the error must be
> local. Yes?
>
> Please explain where the positional argument is located.
>
> Regards,
>
> Rich

The positional argument in question is not one you passed to the
ttk.Checkbutton call, but the ttk.Checkbutton itself that you're passing
to LabelInput as a positional argument after the input_var keyword argument

Alex




More information about the Python-list mailing list