A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-February/123896.html below:

[Python-Dev] why do we allow this syntax?

[Python-Dev] why do we allow this syntax? [Python-Dev] why do we allow this syntax?Oscar Benjamin oscar.j.benjamin at gmail.com
Fri Feb 8 17:17:55 CET 2013
On 8 February 2013 16:10, Benjamin Peterson <benjamin at python.org> wrote:
> 2013/2/8 Chris Withers <chris at simplistix.co.uk>:
>> On 08/02/2013 15:42, Benjamin Peterson wrote:
>>>
>>> 2013/2/8 Chris Withers<chris at simplistix.co.uk>:
>>>>
>>>> Hi All,
>>>>
>>>> Just had a bit of an embarrassing incident in some code where I did:
>>>>
>>>> sometotal =+ somevalue
>>>
>>>
>>> That's just a strange way of expressing
>>>
>>> sometotal = +somevalue
>>
>>
>> Indeed, but why should this be possible? When could it do something useful?
>> :-)
>
> + is a normal overridable operator.

Decimal.__pos__ uses it to return a Decimal instance that has the
default precision of the current Decimal context:

>>> from decimal import Decimal
>>> d = Decimal('0.33333333333333333333333333333333333333')
>>> d
Decimal('0.33333333333333333333333333333333333333')
>>> +d
Decimal('0.3333333333333333333333333333')


Oscar
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4