I'm guessing that what this thread is about is coming up with an API rule that 
makes
providing a set of boolean options available to a function or class in the 
least error prone way.

Its the error prone nature of integer bit masks that is behind the enum 
suggestion I assume.

>From the C tradition we have the integer bit mask which is error prone as 
>there is no type checking that the masks belong to the option flags.

Some APIs use calls with lots of keyword args that you set true or false and 
even none to mean default.

The suggestion for a set of enums from this thread. You would need a class to 
represent a set of a particular enum to get type safety.

List of strings or enums.

You could even use a class that represents the options and set up an instance 
and pass it in. Hard to get wrong.

I can see that all these styles have their place and each designer will pick 
the style they think fits the API they
are designing.

Barry

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to