On Saturday 02 April 2016 00:38:31 Andrew Godwin wrote: > On Fri, Apr 1, 2016 at 11:32 PM, Shai Berger <s...@platonix.com> wrote: > > Hi, > > > > Finally found the time to go through this discussion. > > > > The first note that comes to mind is: > > > > Although it has already been pointed out more than once that positional > > arguments cannot follow keyword arguments, you both (Andrew and Vincent) > > keep > > giving examples such as > > > > # SYNTAX ERROR > > route('sms.receive', sender=r'\+44(?P<local_number>[0-9]+)$', > > > > Consumer) > > > > I believe the reason for that is the clash between the will to preserve > > the current `route(channel, consumer)` syntax, which is like the > > parallel `url(path_regex, view, **kw)` syntax, on one hand; and the > > instinct that the > > identifying parameters should be together, on the other hand. > > > > I think that the latter consideration prevails; unlike the kw parameters > > in url(), which are essentially parameters to the view, the kw > > parameters proposed for channel help select the consumer; and so they > > must be adjacent to > > the channel name -- and hence, the consumer must be the first argument. > > Ah, that's an interesting ordering I hadn't considered before - the problem > is, I would have it (channel, kwargs, consumer) if I could, as generally > when I'm reading the file I want to identify things by route. For that > reason, I still like having the channel at the beginning as it makes it > obvious what the rest of the line is dealing with (websocket? http? etc.) >
Well, in that case I would consider defining the consumer as a required, but keyword (and keyword-only in Python3) argument, specified in the end by convention. Putting it between the channel and channel parameters is ugly IMO. > > A second thought is about multiple keyword arguments: > > > > Is there something about this method you think is better than three > includes? Remember, routing specifies the variable inside the module > (unlike url includes, which only specify the module) so you can still keep > the three routing sets in the one routing.py inside the app. > I somehow missed this, it makes my entire argument moot. Agreed. Thanks, Shai.