Re: [Python-Dev] descriptor __set_name__ and dataclasses

2018-03-27 Thread Nick Coghlan
On 27 March 2018 at 01:17, Eric V. Smith  wrote:
> On 3/26/18 11:10 AM, Eric V. Smith wrote:
>>
>> On 3/26/18 11:08 AM, Nick Coghlan wrote:
>>>
>>> On 27 March 2018 at 00:40, Eric V. Smith  wrote:
>
>
>>> Would it be feasible to define `Field.__set_name__`, and have that
>>> call `default.__set_name__` when the latter exists, and be a no-op
>>> otherwise?
>>
>>
>> A clever idea! I'll look in to it.
>
> It looks like that does work. Thank, Nick!

Cool!

Cheers,
Nick.

-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Symmetry arguments for API expansion

2018-03-27 Thread Chris Barker
I know this is all done, but for completeness’ sake:

I just noticed math.trunc() and __trunc__().

So wouldn’t the “correct” way to check for an integral value be something
like:

obj.__trunc__() == obj

I don’t think this has any bearing on adding is_integer() methods to
numeric objects, but might if we wanted to add a generic is_integer()
function somewhere.

In any case, I don’t recall it being mentioned in the conversation, so
thought I’d complete the record.

-CHB





On Wed, Mar 21, 2018 at 8:31 PM Guido van Rossum  wrote:

> On Wed, Mar 21, 2018 at 6:48 PM, Chris Barker 
> wrote:
>
>> On Wed, Mar 21, 2018 at 4:12 PM, Guido van Rossum 
>> wrote:
>>
>>> Thank you! As you may or may not have noticed in a different thread,
>>> we're going through a small existential crisis regarding the usefulness of
>>> is_integer() -- Serhiy believes it is not useful (and even an attractive
>>> nuisance) and should be deprecated. OTOH the existence of
>>> dec_mpd_isinteger() seems to validate to me that it actually exposes useful
>>> functionality (and every Python feature can be abused, so that alone should
>>> not
>>>
>> )
>
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Symmetry arguments for API expansion

2018-03-27 Thread Robert Smallshire
In the PR I've submitted, that's essentially what I'm doing for the default
Real.is_integer() implementation. The details differ slightly, in that I
rely on the int() constructor to call __trunc__(), rather than introduce a
new dependency on the math module.

On Tue, 27 Mar 2018 at 21:29, Chris Barker  wrote:

> I know this is all done, but for completeness’ sake:
>
> I just noticed math.trunc() and __trunc__().
>
> So wouldn’t the “correct” way to check for an integral value be something
> like:
>
> obj.__trunc__() == obj
>
> I don’t think this has any bearing on adding is_integer() methods to
> numeric objects, but might if we wanted to add a generic is_integer()
> function somewhere.
>
> In any case, I don’t recall it being mentioned in the conversation, so
> thought I’d complete the record.
>
> -CHB
>
>
>
>
>
> On Wed, Mar 21, 2018 at 8:31 PM Guido van Rossum  wrote:
>
>> On Wed, Mar 21, 2018 at 6:48 PM, Chris Barker 
>> wrote:
>>
>>> On Wed, Mar 21, 2018 at 4:12 PM, Guido van Rossum 
>>> wrote:
>>>
 Thank you! As you may or may not have noticed in a different thread,
 we're going through a small existential crisis regarding the usefulness of
 is_integer() -- Serhiy believes it is not useful (and even an attractive
 nuisance) and should be deprecated. OTOH the existence of
 dec_mpd_isinteger() seems to validate to me that it actually exposes useful
 functionality (and every Python feature can be abused, so that alone should
 not

>>> )
>>
> ___
> Python-Dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/rob%40sixty-north.com
>
-- 
*Robert Smallshire | *Managing Director
*Sixty North* | Applications | Consulting | Training
[email protected] | T +47 63 01 04 44 | M +47 924 30 350
http://sixty-north.com
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com