[Python-ideas] Optional static typing -- the crossroads

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Aug 17 12:31:28 CEST 2014


Nicholas Cole wrote:
> On Sun, Aug 17, 2014 at 3:08 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> 
>>    def __init__(self,
>>            description:str, sec_code:str,
>>            vendor_name:str, vendor_inv_num:str,
>>            vendor_rtng:str, vendor_acct:str,
>>            transaction_code:str, vendor_acct_type:str,
>>            amount:int, payment_date:Any)->None:
>
>I had to stare at that block of
> code for a long time to see how many and what type of arguments it
> called.

Pascal's function signature syntax had a nice feature
that everyone else seems to have forgotten about. If you
had multiple parameters of the same type, you only had
to write the type once:

     procedure Init(description, sec_code, vendor_name,
         vendor_inv_num, vendor_rtng, vendor_acct,
         transaction_code, vendor_acct_type, amount: str;
         payment_date: Any)

Disappointingly, Python's annotations make the same
blunder as C, and most other languages since, in
requiring each parameter to have its own individual
annotation.

-- 
Greg


More information about the Python-ideas mailing list