[Python-ideas] Is there a good reason to use * for multiplication?
Joao S. O. Bueno
jsbueno at python.org.br
Mon Oct 15 22:00:27 CEST 2012
On 15 October 2012 16:12, Mike Graham <mikegraham at gmail.com> wrote:
> On Sun, Oct 14, 2012 at 3:57 PM, Mike Meyer <mwm at mired.org> wrote:
>> On Sun, 14 Oct 2012 07:40:57 +0200
>> Yuval Greenfield <ubershmekel at gmail.com> wrote:
>>
>>> On Sun, Oct 14, 2012 at 2:04 AM, MRAB <python at mrabarnett.plus.com> wrote:
>>>
>>> > If it's more than one codepoint, we could prefix with the length of the
>>> > codepoint's name:
>>> >
>>> > def __12CIRCLED_PLUS__(x, y):
>>> > ...
>>> >
>>> >
>>> That's a bit impractical, and why reinvent the wheel? I'd much rather:
>>>
>>> def \u2295(x, y):
>>> ....
>>>
>>> So readable I want to read it twice. And that's not legal python today so
>>> we don't break backwards compatibility!
>>
>> Yes, but we're defining an operator for instances of the class, so it
>> needs the 'special' method marking:
>>
>> 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?
>
" The time machine strikes again!"
What you want is _valid_ in Python, likely since 2.2 -
You will need at least two lines in the file:
# coding:unicode_escape\n
def a():\n\tprint "Helo World"\n\na()
> Mike
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
More information about the Python-ideas
mailing list