Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mapping_context_py3.py 413B

12345678910111213141516171819
  1. # pylint: disable=missing-docstring,invalid-name,too-few-public-methods,no-self-use
  2. from __future__ import print_function
  3. def test(**kwargs):
  4. print(kwargs)
  5. # metaclasses as mappings
  6. class Meta(type):
  7. def __getitem__(cls, key):
  8. return ord(key)
  9. def keys(cls):
  10. return ['a', 'b', 'c']
  11. class SomeClass(metaclass=Meta):
  12. pass
  13. test(**SomeClass)
  14. test(**SomeClass()) # [not-a-mapping]