Your proposal gets a "no, absolutely not" vote from me.
1. We already have a notion of "optional parameters". Parameters
with default values are optional.
2. Your proposed syntax doesn't mention how we'd actually establish
default values for parameters. So it's insufficient to handle
existing code.
3. Your syntax/semantics, as described, can't convey the concept of
optional groups. So it's insufficient to solve the problem it sets
out to solve.
4. Your proposed syntax changes 80% of existing code--any parameter
with a default value. I don't know how you concluded this was
"simpler".
Here's my counter-proposal.
1. We add a new class to inspect named "ParameterGroup". This class
will have only one public member, "parent". ParameterGroup.parent
will always be either None or a different inspect.ParameterGroup
instance.
2. We add a new member to inspect.Parameter named "group". "group"
will be either None or an instance of inspect.ParameterGroup.
3. We add a new method on Parameter named "is_optional()".
"is_optional()" returns True if the function can be called without
providing the parameter. Here's the implementation:
def is_optional(self):4. Textual representations intended for displaying to the user are permitted to use square brackets to denote optional groups. They might also be permitted to use "/" to delimit positional-only parameters from other types of parameters, if the community accepts this.
return (self.default is not self._empty) or (self.group is not None)
bytearray([source, [encoding, [errors]]])
source.group != encoding.groupcurses.window.addch([x, y,] ch, [attr])
encoding.group != errors.group
source.group.parent == None
encoding.group.parent == source.group
errors.group.parent == encoding.group
source.is_optional() == encoding.is_optional() == errors.is_optional() == True
x.group == y.group
x.group != attr.group
x.group.parent == attr.group.parent == None
x.is_optional() == y.is_optional() == attr.is_optional() == True
ch.is_optional() == False