Skip to content

ctx is a defined function parameter that's always overwritten, i.e. never in kwargs #131

Open
@jimdewees

Description

@jimdewees

ctx = kwargs.get('ctx')

>>> class C(object):
...     def __init__(self, ctx=None, *args, **kwargs):
...         print(ctx, kwargs, kwargs.get('ctx'))
...
>>> try:
...     c1 = C('this', ctx='that')
... except TypeError as err:
...     print(err)
...
__init__() got multiple values for argument 'ctx'
>>> try:
...     c2 = C(ctx='this', **{'ctx': 'that'})
... except TypeError as err:
...     print(err)
...
type object got multiple values for keyword argument 'ctx'
>>> c3 = C('this', _ctx='that')
this {'_ctx': 'that'} None
>>> c4 = C(ctx='this is not in kwargs')
this is not in kwargs {} None
>>> c5 = C(**{'ctx': 'neither is this'})
neither is this {} None

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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