Dear 笹原康央,

This sounds interesting. The assignment could be done e.g., like
this.

```python
def assign(variables):
    return f'''
for _variable, _value in (lambda {variables}: locals())(
        *_values, **_assignments
).items():
    exec(f'{{_variable}} = _value')
    '''

def name_update(_namespace, /, *_values, **_assignments):
    return _namespace.update(locals())

name_update(globals(),
            1, 2, *[3,4], **{"b":4}, c=4
            )
exec(assign(
    "a, *args, b, **kwargs"
))

def f():
    name_update(locals(),
        1, 2, *[3,4], **{"b":4}, c=4
    )
    exec(assign(
        "a, *args, b, **kwargs"
    ))
    return locals()

```
This is certainly much more writing than an assignment statement. (It
works also with global and nonlocal variables. One should remove the
side effects, which shouldn't be hard with a context manager for
instance. The code is not for assignment to the variable "_variable",
"_value", or "exec". I haven't thought how to make assignment to any
variable possible. Finally, the necessity to call exec requires care.)

Best regards,
Takuo Matsuoka
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/A5YRYAFQNZE6PKTCTX3YEPY5UNGTYDJB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to