On Wed, Mar 23, 2016 at 08:19:34AM -0300, David Bremner wrote: > W. Trevor King writes: > > from __future__ import print_function > > @@ -232,6 +232,10 @@ class Page (object): > > class HtmlPage (Page): > > _slug_regexp = re.compile('\W+') > > > > + def __init__(self, message_url_template, **kwargs): > > + self.message_url_template = message_url_template > > + super(HtmlPage, self).__init__(**kwargs) > > + > > > @@ -395,6 +400,8 @@ _PAGES['text'] = Page() > > _PAGES['html'] = HtmlPage( > > header=header_template.format(**context), > > footer=footer_template.format(**context), > > + message_url_template=config['meta'].get( > > + 'message-url', 'http://mid.gmane.org/{message-id}'), > > ) > > > > Maybe I'm missing some python knowledged, but it looks the > constructor is defined to take a regular argument for > message_url_template, but only passed in as a keyword. Does this > really work? Yup. From [1]: positional-only: specifies an argument that can be supplied only by position. Python has no syntax for defining positional-only parameters. However, some built-in functions have positional-only parameters (e.g. abs()). I can't find a similar Python 3 glossary, but see [2]. Whether we use: def __init__(self, message_url_template, **kwargs): … or: def __init__(self, message_url_template='foobar', **kwargs): … just controls whether the message_url_template has a default or not, and not whether it can be set via positional or keyword arguments. There is Python syntax for keyword-only arguments, and it would look like [2]: def __init__(self, *, message_url_template, **kwargs): … or: def __init__(self, *, message_url_template='foobar', **kwargs): … in the former case, you'd have to call __init__ with a message_url_template=… keyword argument or you'd get: TypeError: __init__() missing 1 required keyword-only argument: 'message_url_template' With the latter case, calling __init__ without a message_url_template argument would just get you the default value (‘foobar’ in these examples). Cheers, Trevor [1]: https://docs.python.org/2/glossary.html#term-parameter [2]: https://docs.python.org/3/reference/compound_stmts.html#function-definitions -- This email may be signed or encrypted with GnuPG (http://www.gnupg.org). For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy