[issue34554] add match built in function

mokhalid report at bugs.python.org
Fri Aug 31 10:45:23 EDT 2018


New submission from mokhalid <mohammedkhaildson at gmail.com>:

match built-in function feature request:

what is the match function do?
the match function is doing something like if but with quick easy syntax that even beginners can use.

possible syntax:

match(list or string or dictionary):
  condition: event here
  condition: event here
#all conditions are applied at the same time as if not elif and else
#but you use elif or else.

ex:
match(list or string or dictionary):
  condition: event here
  condition: event here
    elif condition: event here
    else: event here
 

example of what I mean:
match([2,5,4,'Hello']):
  2: print('here is 2')
  6: print('here is 6')
    elif 'Hello': ('Hello world')
  8:print('here is 8')
    elif 'python': ('Hello world')
    else: print('MoKhalid')

the output should look like:
here is 2
Hello world
MoKhalid

----------
components: Regular Expressions
messages: 324425
nosy: MoKhaild, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: add match built in function
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34554>
_______________________________________


More information about the Python-bugs-list mailing list