PEP 572 -- Assignment Expressions

Ivo Shipkaliev ivo.shipkaliev at gmail.com
Tue Nov 27 05:48:20 EST 2018


   Hello.
   Maybe it's too late for a discussion, but I just couldn't resist.
   I just found out about this new ":=" operator. I need to ask:

   What is the need for this additional ":" to the "="?
   Why:
         if (match := pattern.search(data)) is not None:
               # Do something with match

   What is wrong with:
         if match = pattern.search(data) is not None:
               # Do something with match

   Assignment expression or assignment statement, it's an assignment,
right? It is very clear to everyone that it's an assignment! Can't it all
just be a "="?
   Thank you very much!


   Kind Regards
   Ivo Shipkaliev



More information about the Python-list mailing list