Open graeme-winter opened 4 years ago
https://www.python.org/dev/peps/pep-3102/ allows
def function(
arg1,
arg2,
*,
keyword_argument_only=True,
no_positional_arguments_allowed_here=True,
)
a possible alternative would be to pass a named tuple instead of up to 14 arguments.
👆 strikes me as a very good idea. The initial positional arguments stay since they are somewhat sine qua non however any optional arguments should be added with parameter names attached, I like this and it will make it much quicker to debug.
Says introduced in 3.0, was it backported?
Not 100% obvious how to make this play nice with boost::python
exported classes though e.g. Panel
🤔
Not backported to my knowledge. If it were backported it would be exceedingly hacky. This would be a breaking change, and therefore the Python 2.7 deprecation ticket would apply.
For boost::python
the answer is approximately no, which is not entirely surprising given that boost::python
hasn't seen much active development for a long time.
The straightforward solution would be to wrap the object within Python.
e.g. in
convention dictates that all arguments after
image_size
should be labelled in the calling routine - they are not in some cases (e.g. in tests) where they are assumed to follow in the correct order. This makes the API fragile.