current scenario -
- for certain types, there is no way to match them,
mppngprxy = (type.__dict__)
dct_kys = {'a': 1}.keys()
dct_vls = {'a': 1}.values()
dct_items = {'a': 1}.items()
for i in [mppngprxy, dct_kys, dct_vls, dct_items]:
match i:
case type(type.__dict__): print('mapping proxy') # it does not work
case ???: print('dictionary keys')
case ???: print('dictionary values')
case ???: print('dictionary items')
- use of match case on types that could be traversed is also a bit confusing, as,
enmrt = enumerate([1, 2, 3])
for i in [enmrt]:
match i:
case enumerate(): print('enumerate')
gives, enumerate
as output, similar holds true for range
also.
but there is no way to match, iter(list([1, 2, 3]))
as there is nothing like specifying list_iterator()
after case, similar pattern for list_reverseiterator
, set_iterator
, …
- this one is a bit confusing,
1 == True
and0 == False
, both giveTrue
, but,
match 1:
case True: print('yes')
does not match, similar for match 0:
to case False:
.
one more thing is should 1
and 0
match with bool()
also, as again 1 == True
and 0 == False
- use of
NotImplemented
in case block, currently it acts as a wildcard.
match 1:
case NotImplemented: print('1')
case _: print('2')
gives the error,
SyntaxError: name capture 'NotImplemented' makes remaining patterns unreachable
this is also a bit controversial
expected scenario -
- if there is a way to get
mappingproxy
,dict_keys
,dict_values
,dict_items
matched, then inform me, if there is no way, then probably there should be a way - there should be a way to get
list_iterator
,set_iterator
… matched also. - controversial but one possibility is
1
should match withTrue
andbool()
, similar for0
withFalse
andbool()
-
NotImplemented
should not act as a wildcard, either just raise an error ifNotImplemented
is specified after case, or add a way to get it matched to a function which raisesNotImplemented