Opened 7 years ago

Last modified 5 years ago

#6304 enhancement new

— at constants how to doesn't provide examples of how to test the value of composed flagsVersion 1

Reported by: Wilfredo Sánchez Vega Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description (last modified by Wilfredo Sánchez Vega)

The constants how to doesn't provide examples of how to test the value of flags. If shows you how to create them, and how to compose them. For example, here's composition using OR:

>>> Permission.USER_READ | Permission.USER_WRITE
<Permission={USER_READ,USER_WRITE}>

So let's say I have the result of that in a mode variable. How do I test whether the USER_READ flag is present in mode?

Glyph suggested that I use composition using AND to check, which got me writing ticket #6303. How to check the composed values seems like an important thing to document.

The .value attribute is documented, but not in a super useful way. Basically, if you call that you get back a number that you shouldn't think about. There's no mention that 0 means no flags, and non-zero means some flags, which is probably all you need to know about what those values mean.

The above information might help one understand how one might implement the format method example at the bottom, which just looks like magic unless you are going to go into FilePath and look at the implementation. How are those 'rw-' strings computed?

Change History (1)

comment:1 Changed 7 years ago by Wilfredo Sánchez Vega

Description: modified (diff)
Note: See TracTickets for help on using tickets.