Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: MRAB Newsgroups: comp.lang.python Subject: Re: learning python. learning defining functions . need help Date: Fri, 22 Jul 2016 19:36:56 +0100 Lines: 11 Message-ID: References: <432aeb03-ea14-4ece-8e5b-a7521cf12b84@googlegroups.com> <20160722114118.6a809d29@imp> <3379130e-1205-9f02-61c6-e30aee47435f@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de EgfICGzKetLqew2vVubNyACXwqvAx1L7dIJli6XPddRA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'none,': 0.05; 'subject:help': 0.07; 'dict': 0.09; 'subclass': 0.09; '2016': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'justin': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:python.': 0.16; 'wrote:': 0.16; 'subject:need': 0.18; 'handles': 0.20; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'checking': 0.27; 'fri,': 0.27; 'subject:learning': 0.29; 'classes': 0.30; '-0700': 0.33; 'could': 0.35; 'replace': 0.35; "isn't": 0.35; 'stock': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:192': 0.39; 'well.': 0.40; 'to:addr:python.org': 0.40; 'subject:. ': 0.67; 'jul': 0.72; 'dict,': 0.84; 'subject: . ': 0.84; 'walters': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.2 cv=dMLko6Rb c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=S8vV_Mvqr_kS00Pp6hIA:9 a=FgcEZ7H6pukA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 X-AUTH: mrabarnett@:2500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: <20160722114118.6a809d29@imp> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <3379130e-1205-9f02-61c6-e30aee47435f@mrabarnett.plus.com> X-Mailman-Original-References: <432aeb03-ea14-4ece-8e5b-a7521cf12b84@googlegroups.com> <20160722114118.6a809d29@imp> Xref: csiph.com comp.lang.python:111770 On 2016-07-22 16:41, D'Arcy J.M. Cain wrote: > On Fri, 22 Jul 2016 08:21:17 -0700 > justin walters wrote: >> You could also replace that line with: >> >> if stock is None or type(stock) != dict: > > Use isinstance(). That handles classes that subclass dict as well. > If you're checking that it's a dict, there's no need to check whether it's None, because None isn't a dict either!