Some Python standard libraries use flags like this:
re.match(pattern, str, re.MULTILINE | re.IGNORECASE)
I am wondering, how to implement that, if you are creating a class yourself. I have searched the Internet and found that: Python: passing flags to functions That question is not satisfying for me, as it only show's the approach of saying
bla.function(argument, flag1=0, flag3=1)
But I really want it like
bla.function(argument, bla.SOMEFLAG | bla.SOMEOTHERFLAG)
is this possible?
Furthermore is it possible to create these flags, without letting them refer to an actual value?, so you really ask for bla.SOMEFLAG in the code and not for an int, that is represented by the flag? An example usage for that would be:
mask_list = [
[ 15, "foo", "bar"],
[bla.TRANSPARENT, "egg", 14.3],
[ (4,7,2), {"name":"john"}, bla.TRANSPARENT]
]
where mask_list represents a mask(containing any elements), which can later be compared to another list by a function, all indexes where a bla.TRANSPARENT flag is set, get ignored by the comparison.
If someone could pass me a link to a file, where this is explained, or could come up with a simple explanation, I would be really grateful. (I am using Python3)
Thanks in advance!