Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'arguments': 0.07; 'caller': 0.07; 'suppose': 0.07; 'python': 0.09; 'arg': 0.09; 'kwargs': 0.09; 'positional': 0.09; 'similar,': 0.09; 'spec': 0.09; 'subject:Function': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; '(note': 0.16; 'defaults.': 0.16; 'inputs': 0.16; 'wrote:': 0.17; 'assignment': 0.22; 'cc:2**0': 0.23; 'dependent': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '(which': 0.26; 'used,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'optional': 0.29; 'this.': 0.29; 'keyword': 0.30; 'function': 0.30; 'sense': 0.31; 'december': 0.32; 'could': 0.32; 'received:google.com': 0.34; 'list': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'possible': 0.37; 'two': 0.37; 'ones': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'called': 0.39; 'header:Received:5': 0.40; 'here': 0.65; 'asterisk': 0.84; 'oscar': 0.84; 'vain': 0.84; 'valid)': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=XBGWlvjAsdlnjilyL5pstT9KoGzamq5TP2y8Evs3ryQ=; b=JKwrgwy3efZljHWDjzYWGABM9VL0LDbsk9WqcY9k2GHgFxMZOIGGmrGm/mX0aYlUG1 UxpTjhJAfQJLJX3CcGFSUZdnFsluzzlSERzfRziBr3CuqZJZFL+VWWj3bYT1XRhObQA7 eNAfBEKHJboTynycnPfCROpWuaXMTp4jLr+nh4+W2HygUkKgoxXyMyDK9UGHL8I6QTT9 L9SjDHi7WfhWhoP5vZoU1fGcij5JCkBKnxOTrMR6mlg6dQqthkj8y559EfDNd/DQLtWV lfm/HzlKeSQuUm34RIaFDfq89LXQTmVMg+GgkToI+hiPSb2LwKrSB7sextjWh0sLdUI2 Oe0Q== MIME-Version: 1.0 In-Reply-To: References: <92097A6A775D5147B1078E3F15430B9234A0F238@prato.activenetwerx.local> Date: Thu, 27 Dec 2012 21:07:27 +0000 Subject: Re: Function Parameters From: Oscar Benjamin To: "Joseph L. Casale" Content-Type: text/plain; charset=ISO-8859-1 Cc: =?ISO-8859-1?Q?Python_=5Bpython=2Dlist=40python=2Eorg=5D?= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356642448 news.xs4all.nl 6894 [2001:888:2000:d::a6]:55147 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35653 On 27 December 2012 20:47, Joseph L. Casale wrote: >> Don't use kwargs for this. List out the arguments in the function >> spec and give the optional ones reasonable defaults. > >> I only use kwargs myself when the set of possible arguments is dynamic >> or unknown. > > Gotch ya, but when the inputs to some keywords are similar, if the function is called > with two of three (which is valid) and the arg name isn't used, the assignment is order > dependent and arbitrary in a sense and I can not distinguish. > > It would be nice if you could force the keyword to be mandatory to forgo the assumption > in assignment like kwargs provides with gets. I suppose all the time wasted here is in vain > as the caller could blunder elsewhere... In Python 3 you can do this using keyword-only arguments like so (note the asterisk that separates keyword arguments from positional arguments): def my_func(self, *, some_key=MISSING, another_key=MISSING): Oscar