[Python-ideas] More friendly access to chmod

Chris Angelico rosuav at gmail.com
Mon Jan 11 19:12:20 EST 2016


On Tue, Jan 12, 2016 at 7:44 AM, Andrew Barnert <abarnert at yahoo.com> wrote:
> On Jan 11, 2016, at 08:53, Chris Angelico <rosuav at gmail.com> wrote:
>>
>>> On Tue, Jan 12, 2016 at 3:49 AM, Andrew Barnert <abarnert at yahoo.com> wrote:
>>>> On Jan 11, 2016, at 04:02, Ram Rachum <ram at rachum.com> wrote:
>>>>
>>>> I've chosen += and -=, despite the fact they're not set operations, because Python doesn't have __inand__.
>>>
>>> For a property that acts like a number, and presumably is implemented as a subclass of int, this seems like a horribly confusing idea.
>>
>> I would expect it NOT to be a subclass of int, actually - just that it
>> has __int__ (and maybe __index__) to convert it to one.
>
> If you read his proposal, he wants oct(path.chmod) to work. That doesn't work on types with __int__.
>
> Of course it does work on types with __index__, but that's because the whole point of __index__ is to allow your type to act like an actual int everywhere that Python expects an int, rather than just something coercible to int. The point of PEP
> 357 was to allow numpy.int64 to act as close to a subtype of int as possible without actually being a subtype.

This is what I get for not actually testing stuff. I thought having
__int__ would work for oct. In that case, I would simply recommend
dropping that part of the proposal; retrieving the octal
representation can be spelled oct(int(x)), or maybe x.octal or
x.octal(). This is NOT an integer; it's much closer to a set of
bitwise enumeration.

ChrisA


More information about the Python-ideas mailing list