UserLinux chooses Python as "interpretive language" of choice

Bengt Richter bokr at oz.net
Sun Dec 21 15:47:35 EST 2003


On Sun, 21 Dec 2003 14:30:36 -0500, "Terry Reedy" <tjreedy at udel.edu> wrote:

>
>"John Roth" <newsgroups at jhrothjr.com> wrote in
>message news:vub584opb8sd0f at news.supernews.com...
>> Well, the basic idea was simply to make the ()
>optional for functions
>> with no parameters.
>
>In mathematics (except in lambda calculus), there
>is generally no such thing since functions
>generally have no side effects and hence no-param
>function = constant, and name with no parens is
>same as normal name ref to constant, whether
>number, function, or other mathematical object.
>On the other hand, one-param functions *are* ofter
>written without parens for simple args.  Hence I
>suspect that above would lead to the suggestion
>that parens also be optional for single-arg funcs.
>
>The overloading of no-op juxtaposition to mean
>either * or () (alternatively, the interpretation
>of function * number as function(number)) is
>rather cute.
>
 >>> class MulFun(object):
 ...     def __init__(self, f): self.f = f
 ...     def __mul__(self, other): return self.f(other)
 ...
 >>> r = MulFun(repr)
 >>> r * 123
 '123'
 >>> r * 'Happy Holidays'
 "'Happy Holidays'"

Regards,
Bengt Richter




More information about the Python-list mailing list