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

Ryan Gonzalez rymg19 at gmail.com
Sat Aug 16 22:48:10 CEST 2014


Maybe that point of interest could be solved by using some kind of type
class/interface(in the Obj C/Java sense). That way, external types that the
user has no control of can be added to the interface.


On Sat, Aug 16, 2014 at 3:22 PM, Ethan Furman <ethan at stoneleaf.us> wrote:

> 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~
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
Ryan
If anybody ever asks me why I prefer C++ to C, my answer will be simple:
"It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that was
nul-terminated."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140816/3e7eb889/attachment.html>


More information about the Python-ideas mailing list