Skip to content

Need easier way to pass along kwargs with same name as a named arg #10

@wch

Description

@wch

Python doesn't like it if a kwarg has the same name as an explicitly named argument. This can cause problems when a function passes kwargs to a tag function, when the call to the tag function has a named argument like class_. For example:

from htmltools import *

def foo(text, **kwargs):
    return div(text, class_="foo", **kwargs)

foo("hi")
#> <div class="foo">hi</div>

foo("hi", class_="extra_class")
#> TypeError: htmltools.tags.div() got multiple values for keyword argument 'class_'

One possibility is for the tag function to accept a dict and merge it in with its kwargs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions