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


Groups > comp.lang.python > #87981

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

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.004
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; 'exception,': 0.09; 'fix.': 0.09; 'subject:Function': 0.09; 'try:': 0.09; 'valueerror:': 0.09; 'def': 0.12; '......': 0.16; 'combinations': 0.16; 'googled': 0.16; 'ivan': 0.16; 'readable': 0.16; 'subject:avoiding': 0.16; 'subject:combinations': 0.16; 'tweak': 0.16; 'valueerror': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'message-----': 0.19; 'input': 0.22; 'outlook': 0.22; 'case.': 0.24; 'flows': 0.24; 'settings.': 0.24; 'order.': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'function': 0.29; 'raise': 0.29; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; '25,': 0.31; 'context,': 0.31; 'file:': 0.31; 'stuff': 0.32; 'url:python': 0.33; 'implemented': 0.33; 'except': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; '+0200,': 0.36; 'url:listinfo': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'too': 0.37; 'email addr:python.org': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr :python-list': 0.38; 'skip:- 10': 0.38; 'previous': 0.38; 'subject:': 0.39; 'skip:b 40': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'url:mail': 0.40; 'how': 0.40; 'read': 0.60; 'catch': 0.60; 'guy': 0.60; 'full': 0.61; 'new': 0.61; 'march': 0.61; "you're": 0.61; 'back': 0.62; "you've": 0.63; 'address': 0.63; 're:': 0.63; 'received:79': 0.64; 'email name:python-list': 0.65; 'mar': 0.68; 'answer.': 0.68; '2015': 0.84; 'kicking': 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=PgR8B0lDs7dQZTYnNklaCEuM4yDocrzdtXGtPGPH5DU=; b=US2hm/lQ0f+sCIshd0NHZnS1Xs1YtE31/prJlWOhqhTSJSVuvIJTMwXXyHJpNzEMjZ 9Pf2svMpawAfuVz4LYHncZLHT9Ddvup/9eQGbr80/4/yCVKNWUkTcLaZ8t29yjO930av 44XGdIE/vDl4FjZGGbgmhw+4j+Urovr4c5HMJz5WnKsehHkTfbdRg+p0rWomAGwlJ8Sq FS7UQV8Ze8XVOo2xeBOux7Bj09yjtcg62dja13AHBKFEl+QF9WiH+nHV82okQ3lrn26e 592LoNAJwlORZS6ITKY/dONNLfgCtD1x+lC+dEsIVwByK4Y+jElVt/hqZl0PfJG7hx5e KpQw==
X-Received by 10.181.27.199 with SMTP id ji7mr40588992wid.76.1427316228268; Wed, 25 Mar 2015 13:43:48 -0700 (PDT)
From "Ivan Evstegneev" <webmailgroups@gmail.com>
To "'Rob Gaddi'" <rgaddi@technologyhighland.invalid>, <python-list@python.org>
References <009d01d06723$38860d50$a99227f0$@gmail.com> <meuvkb$e5t$1@ger.gmane.org> <mailman.158.1427313051.10327.python-list@python.org> <mev4he$amn$5@dont-email.me>
In-Reply-To <mev4he$amn$5@dont-email.me>
Subject RE: Function Defaults - avoiding unneccerary combinations of arguments at input
Date Wed, 25 Mar 2015 22:43:44 +0200
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding 7bit
X-Mailer Microsoft Outlook 14.0
Thread-Index AQJmhzuVcfXrhgB79AcdClmCd0UxfgEFs1iiAVeTeX8CQpQxsZvca2YA
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.161.1427316235.10327.python-list@python.org> (permalink)
Lines 73
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427316235 news.xs4all.nl 2915 [2001:888:2000:d::a6]:58056
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87981

Show key headers only | View raw



> -----Original Message-----
> From: Python-list [mailto:python-list-
> bounces+webmailgroups=gmail.com@python.org] On Behalf Of Rob Gaddi
> Sent: Wednesday, March 25, 2015 22:07
> To: python-list@python.org
> Subject: Re: Function Defaults - avoiding unneccerary combinations of
> arguments at input
> 
> On Wed, 25 Mar 2015 21:50:40 +0200, Ivan Evstegneev wrote:
> 
> > Hello again ^_^,
> >
> > Googled a bit, and found only one, a "ValueError" exception, but still
> > don't understand how it should be implemented in my case.
> >
> > Should my code look like this one:
> >
> > def  my_fun(history=False, built=False, current=False, topo=None,
> > full=False, file=None):
> > 	try:
> > 		if currnet and full:
> > 			do something_1
> > 		elif current and file:
> > 			do something_2
> > 		elif history and full and file:
> > 			do something_3
> >
> > 	except ValueError:
> > 		print("No valid input! Please try again ...")
> >
> >
> > 	...... some code here..............
> >
> >
> > Or I'm just too optimistic ^_^?
> >
> > Thanks in advance,
> >
> > Ivan.
> >
> 
> A) Please don't top-post.  Put your new stuff below previous context, so
it
> flows in readable order.
> 
> B) You've got the concept backwards.  You're not trying to catch a
ValueError
> because one came up below your function.  Your function was called
> incorrectly, and you're kicking the responsibility for dealing with it
back to the
> guy who got it wrong.
> 
> def my_fun(....):
>     if invalid_argument_combination:
>        raise ValueError('Hey jerk, read the documentation.')
> 
>     # otherwise you do your thing in here.
> 
> 
> --
> Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email
> address domain is currently out of order.  See above to fix.
> --
> https://mail.python.org/mailman/listinfo/python-list




Ok thanks fo the answer. Got it. About top-posting... will need to tweak
Outlook settings.

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


Thread

RE: Function Defaults - avoiding unneccerary combinations of arguments at input "Ivan Evstegneev" <webmailgroups@gmail.com> - 2015-03-25 21:50 +0200
  Re: Function Defaults - avoiding unneccerary combinations of arguments at input Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-03-25 20:07 +0000
    RE: Function Defaults - avoiding unneccerary combinations of arguments at input "Ivan Evstegneev" <webmailgroups@gmail.com> - 2015-03-25 22:43 +0200

csiph-web