Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87968

RE: Function Defaults - avoiding unneccerary combinations of arguments at input

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <webmailgroups@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'skip:[ 20': 0.04; 'elif': 0.05; 'defaults': 0.07; 'wednesday,': 0.07; 'arguments': 0.09; 'function:': 0.09; 'instances.': 0.09; 'subject:Function': 0.09; 'way:': 0.09; 'def': 0.12; 'jan': 0.12; '"current': 0.16; '(actually': 0.16; '......': 0.16; 'combinations': 0.16; "function's": 0.16; 'ivan': 0.16; 'reedy': 0.16; 'subject:avoiding': 0.16; 'subject:combinations': 0.16; 'wrote:': 0.18; 'message-----': 0.19; 'input': 0.22; 'error': 0.23; 'instance,': 0.24; 'question': 0.24; 'options': 0.25; 'header:In- Reply-To:1': 0.27; 'to:2**1': 0.27; 'function': 0.29; 'raise': 0.29; 'url:mailman': 0.30; 'code': 0.31; '25,': 0.31; '>>>>': 0.31; 'file:': 0.31; 'url:python': 0.33; 'common': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'there': 0.35; 'instances': 0.36; 'url:listinfo': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; "i'll": 0.36; 'url:org': 0.36; 'email addr:python.org': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr :python-list': 0.38; 'skip:- 10': 0.38; 'pm,': 0.38; 'little': 0.38; 'subject:': 0.39; 'skip:b 40': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'full': 0.61; 'march': 0.61; 're:': 0.63; 'such': 0.63; 'choose': 0.64; 'received:79': 0.64; 'email name :python-list': 0.65; 'here': 0.66; 'on...': 0.68; 'default': 0.69; '2015': 0.84; 'condition.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:references:in-reply-to:subject:date:message-id:mime-version :content-type:content-transfer-encoding:thread-index :content-language; bh=1qBc68ngfzXekERGYGIX3+KC5xQqcTkH4cXJVXmWBF8=; b=oBc12XeMdx7hVeYA0u3/acOspHnLlBjN/KjA3uQ93hVMY0OJTfzQ5AfdRjxET+IiPy 94nTQfZ4RX5AZBN6wJ2k/1K7OBmeD/C2gceBd2K0e/msAhFQvkD92prRu0EvdI/awhlR KjGPFeWBxr6wOO9aQqEfLG2d9b2bdYWyF/eHhaNMVjk/enQ1lkL8Fz5VMMZyrME4XK7S FwvtBYZKAdJN/suARv4BFi6PdbRpKIqq7a+27BHahTZGMqIcLWj/tGr5Bikz4sLXiMeb 1WwIG8EDgzvN2s1d6ZBkY5LlF4xue8HsWWj4FDq+huFjeUxvGIwsBvgy/DSq9omSSOV8 gTJQ==
X-Received by 10.180.105.2 with SMTP id gi2mr40374482wib.62.1427311376677; Wed, 25 Mar 2015 12:22:56 -0700 (PDT)
From "Ivan Evstegneev" <webmailgroups@gmail.com>
To "'Terry Reedy'" <tjreedy@udel.edu>, <python-list@python.org>
References <009d01d06723$38860d50$a99227f0$@gmail.com> <meuvkb$e5t$1@ger.gmane.org>
In-Reply-To <meuvkb$e5t$1@ger.gmane.org>
Subject RE: Function Defaults - avoiding unneccerary combinations of arguments at input
Date Wed, 25 Mar 2015 21:22:52 +0200
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding 7bit
X-Mailer Microsoft Outlook 14.0
Thread-Index AQJmhzuVcfXrhgB79AcdClmCd0UxfgEFs1iim/klzyA=
Content-Language en-us
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.157.1427311384.10327.python-list@python.org> (permalink)
Lines 67
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427311384 news.xs4all.nl 2886 [2001:888:2000:d::a6]:49069
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87968

Show key headers only | View raw


Hi Terry, 

Thanks for answer, I'll google these stdlib instances.


Sincerely,

Ivan.

> -----Original Message-----
> From: Python-list [mailto:python-list-
> bounces+webmailgroups=gmail.com@python.org] On Behalf Of Terry Reedy
> Sent: Wednesday, March 25, 2015 20:43
> To: python-list@python.org
> Subject: Re: Function Defaults - avoiding unneccerary combinations of
> arguments at input
> 
> On 3/25/2015 1:43 PM, Ivan Evstegneev wrote:
> > Hello all ,
> >
> >
> > Just a little question about function's default arguments.
> >
> > Let's say I have this function:
> >
> > def  my_fun(history=False, built=False, current=False, topo=None,
> > full=False, file=None):
> > 	if currnet and full:
> > 		do something_1
> > 	elif current and file:
> > 		do something_2
> > 	elif history and full and file:
> > 		do something_3
> >
> >
> > 	...... some code here..............
> >
> > and so on...
> >
> > I won't cover all the possibilities here (actually I don't use all of
> > them ^_^).
> >
> > The question is about avoiding the response for unnecessary
> combinations?
> >
> > For instance, if user will call function this way:
> >
> >
> >>>> my_fun(current=True, full=True, topo='some str', file="some_file")
> >
> > That will lead to function's misbehavior. As a particular case it will
> > choose "current and full" condition.
> >
> >
> > What is the common accepted way to deal with such unwanted situations?
> 
> Raise a value error for illegal combinations.  There are a few instances
in the
> stdlib where 2 of several options are mutually incompatible.
> 
> 
> --
> Terry Jan Reedy
> 
> --
> https://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Function Defaults - avoiding unneccerary combinations of arguments at input "Ivan Evstegneev" <webmailgroups@gmail.com> - 2015-03-25 21:22 +0200

csiph-web