Logo
Explore Help
Register Sign In
fengqi/lv_micropython
1
0
Fork 0
You've already forked lv_micropython
Code Issues Pull Requests 1 Actions Packages Projects Releases Wiki Activity
lv_micropython/tests/basics/fun_calldblstar.py

23 lines
383 B
Python
Raw Normal View History

py: Implement positional and keyword args via * and **. Extends previous implementation with * for function calls to * and ** for both function and method calls.
2014-03-30 21:21:24 +01:00
# test calling a function with keywords given by **dict
def f(a, b):
print(a, b)
f(1, **{'b':2})
f(1, **{'b':val for val in range(1)})
py/runtime: Check that keys in dicts passed as ** args are strings. Prior to this patch the code would crash if a key in a ** dict was anything other than a str or qstr. This is because mp_setup_code_state() assumes that keys in kwargs are qstrs (for efficiency). Thanks to @jepler for finding the bug.
2018-03-30 11:09:00 +11:00
try:
f(1, **{len:2})
except TypeError:
print('TypeError')
py: Implement positional and keyword args via * and **. Extends previous implementation with * for function calls to * and ** for both function and method calls.
2014-03-30 21:21:24 +01:00
# test calling a method with keywords given by **dict
class A:
def f(self, a, b):
print(a, b)
a = A()
a.f(1, **{'b':2})
a.f(1, **{'b':val for val in range(1)})
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 167ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API