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

Ethan Furman ethan at stoneleaf.us
Sat Aug 16 22:22:48 CEST 2014


As a test case for what code may soon look like, here's a bit from one of my code bases:


--------------------------------------------------------------------
class ACHPayment(object):
     """A single payment from company to a vendor."""

     def __init__(self,
             description, sec_code,
             vendor_name, vendor_inv_num, vendor_rtng, vendor_acct,
             transaction_code, vendor_acct_type, amount, payment_date):
         """
         description:  10 chars
         sec_code: 'CCD' or 'CTX'
         vendor_name: 22 chars
         vendor_inv_num: 15 chars
         vendor_rtng: 9 chars
         vendor_acct: 17 chars
         transaction_code: ACH_ETC code (enum)
         vendor_acct_type: 'domestic' or 'foreign'
         amount: 10 digits (pennies)
         payment_date: date payment should occur on (datetime.date type class)
         """
--------------------------------------------------------------------


The question:  what would this look like with type annotations?  As a point of interest, the last parameter, 
payment_date, can be /anything/ that quacks like a datetime.date -- I tend to use my own dbf.Date class, which 
subclasses object, not datetime.date itself.

--
~Ethan~


More information about the Python-ideas mailing list