Implicit lists

Paul Rubin phr-n2003b at NOSPAMnightsong.com
Mon Feb 3 18:34:22 EST 2003


Beni Cherniavsky <cben at techunix.technion.ac.il> writes:
> Sure, this is a wart.  Since writing singleton tuples is awkward [2]_,
> I suggest adding a __div__ method to strings that will accept a single
> arg and slowly deprecating the __mod__ exception for a single arg::
> 
>     "%d" / 1          # My suggestion.
>     "%d,%d" % (1,2)   # Stays as now.
>     "%d" % (1,)       # Perfectly legal, should stay (but will be
>                       # rarely used, mainly when the tuple is
>                       # computed).
>     "%d" % 1          # To be deprecated.

The whole string modulo thing is a wart and should be replaced with a
sprintf function like every other language uses.

The one operator overloading idea for strings that I like is a unary
minus sign for interpolation:

    print -"foo is $foo"

But that idea got no response at all last time I posted it.




More information about the Python-list mailing list