[Python-ideas] Is there a good reason to use * for multiplication?

Jasper St. Pierre jstpierre at mecheye.net
Mon Oct 15 21:37:32 CEST 2012


On Mon, Oct 15, 2012 at 3:12 PM, Mike Graham <mikegraham at gmail.com> wrote:
>> def __\u2295__(self, other):
>>
>> Now *that's* pretty!
>>
>>     <mike
>
>
> IMO it's essential that we add source code escapes. Imagine the
> one-liners this will allow!
>
>     def f(xs):\n\ttry:\n\t\treturn x.pop()\n\texcept ValueError\n\t\treturn None
>
> Can we get this fix applied in Python 2.2 and up?

Yeah, this is how Java works, and it's one of the best features of the
language, because any valid program can be expressed using ASCII only.

Of course, it means that there are going to be some edge cases. Like, now:

    print "\n"

will be an invalid program, since the newline escape will be
translated before the source is tokenized. But who does that? It's
just a small price to pay for the big wins of having any program
expressed in simple ASCII.

> Mike
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas



-- 
  Jasper



More information about the Python-ideas mailing list