Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'wrong,': 0.09; 'python': 0.11; 'code?': 0.16; 'expect,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'given,': 0.16; 'rarely': 0.16; 'subject:type': 0.16; 'traceback.': 0.16; 'exception': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'examples': 0.20; 'aug': 0.22; 'questions:': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'usually': 0.31; 'probably': 0.32; 'languages': 0.32; 'subject:the': 0.34; 'something': 0.35; 'done.': 0.35; 'received:google.com': 0.35; 'really': 0.36; "didn't": 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'full': 0.61; 'simply': 0.61; "you're": 0.61; 'production': 0.68; 'subject:Check': 0.95; '2013': 0.98 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 :content-type; bh=HK8zYfMd7bz7572WEcsLaFVV8c++Goezo7iaBkfn3c0=; b=m8nbRUDfbDPaQyc/YelKs533mlecbmOwjvg8Kas3c9sj/GkJ/TG1KBrMU793c/iDzp AbrMTeleUy2C4mnvcI0rRjuRRnEI+dVrOkNY1EJEfqQWxkibTsPqK36DL9IHvx2Czuo/ IfwmKpizyGhTPZs/DmXESfAh4P2pz3Ot/IMQzIO7zzBzwijJU7cNo6xfkf0zuL+zTYak aKMZsiZ7LEFU0NW+P924L4ubD3M4UcgBa5n/Sj68RGJTByHm4MXxCuITdolnpc45Aka3 o8N73MbdigpsXe5oKyLtGNN4Wy2N9mCZXT5dwcsgrqFw3C459I7wNn4I58rn81EGQvPC WHaA== MIME-Version: 1.0 X-Received: by 10.66.171.77 with SMTP id as13mr972334pac.170.1376746265421; Sat, 17 Aug 2013 06:31:05 -0700 (PDT) In-Reply-To: <185a0a88-9515-43e6-ae65-73d86b0299e7@googlegroups.com> References: <185a0a88-9515-43e6-ae65-73d86b0299e7@googlegroups.com> Date: Sat, 17 Aug 2013 14:31:05 +0100 Subject: Re: Check for the type of arguments From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376746274 news.xs4all.nl 15936 [2001:888:2000:d::a6]:41744 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52627 On Sat, Aug 17, 2013 at 1:34 PM, Fernando Saldanha wrote: > Writing in other languages I usually check the type and values of function arguments. In the Python code examples I have seen this is rarely done. > > Questions: > > 1) Is this because it would be "unpythonic" or just because the examples are not really production code? It's unpythonic. The normal thing to do is simply use the object you're given, and if something goes wrong, the exception will have a full traceback. And if you don't notice that it isn't what you expect, well, it probably didn't matter! ChrisA