Opened 7 years ago

Last modified 4 years ago

#6304 enhancement new

— at constants how to doesn't provide examples of how to test the value of composed flagsInitial Version

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


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

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 (0)

Note: See TracTickets for help on using tickets.