[OT] New to Python: Features

Alex Martelli aleaxit at yahoo.com
Thu Oct 7 12:13:14 EDT 2004


Richard Blackwood <richardblackwood at cloudthunder.com> wrote:
   ...
> Oh no, I thought I wrote that accident.  I don't like any brackets or
> else.  I like to write:   foo x, y   or    foo: x,y

I know, but since brackets (in normal CS jargon at least) mean [ ] and
what's used for calls are instead parentheses, ( ) , we were horsing
around about that.  Simple juxtaposition of identifiers, and colon, are
not operators in Python, so you can't overload them.

> Are you saying that if I have only one argument then I may drop the 
> parenthesis? Naw, your not saying that.

Right, I'm not -- and it's not just about syntax sugar.  When you
mention a name, in Python, you ARE doing just that: mentioning a name.

x = y

ALWAYS means to give name x to one more reference to the same object y
refers to.  This incredibly simple and powerful rule is NEVER going to
change with complications and qualifications such as 'unless y refers to
objects with certain characteristics in which case...' -- NEVER.  All
sort of callable objects are first-class, are first and foremost
objects, and mentioning them just gets a reference, no more, no less.

So, calling functions (and other callables) without arguments will never
be done by just mentioning a bare name referring to the callable object;
that would make callables deeply different from everything else, not
truly first-class.  I'm pretty sure that parentheses after the name will
remain the only normal way to perform a call (the 'apply' built-in is
basically obsolete).  If this is the case for functions without
arguments, it would be truly weird to have the rule change when
arguments are present.  Python is not and will never be about offering
several different syntax variants for identical operations just to
satisfy varying tastes in the field of syntax sugar...


Alex



More information about the Python-list mailing list