Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Igor Korot Newsgroups: comp.lang.python Subject: Re: Python Error message Date: Thu, 4 Aug 2016 12:09:33 -0400 Lines: 73 Message-ID: References: <710599b6-b8c3-4f5a-a3dd-48757b816a44@googlegroups.com> <57a36593$0$1590$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de L8nBqRhiqieclREXjAcqoQdbY7B7kn7vsvJJamnM01oQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'debug': 0.04; 'subject:Python': 0.05; 'except:': 0.07; 'subject:Error': 0.07; 'cc:addr:python-list': 0.09; 'exception,': 0.09; 'script,': 0.09; 'throw': 0.09; 'bug': 0.10; 'url:blog': 0.10; 'python': 0.10; 'exception': 0.13; 'output': 0.13; 'thu,': 0.15; '"your': 0.16; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'somewhere.': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'worse.': 0.16; 'worst': 0.16; 'wrote:': 0.16; 'try:': 0.18; ';-)': 0.18; 'project,': 0.18; 'steve': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'first,': 0.20; 'fix': 0.21; 'exceptions': 0.22; 'exists.': 0.22; 'rid': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'script': 0.25; 'supported': 0.27; 'error': 0.27; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'back.': 0.27; 'said,': 0.27; "i'm": 0.30; 'print': 0.30; 'url:mailman': 0.30; 'code': 0.30; '"the': 0.32; '[1]': 0.32; 'problem': 0.33; 'url:python': 0.33; "d'aprano": 0.33; 'skip:j 20': 0.33; 'steven': 0.33; 'url:listinfo': 0.34; 'server': 0.34; 'received:google.com': 0.35; 'behind': 0.35; 'could': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'subject:: ': 0.37; 'things': 0.38; 'detail': 0.38; 'skip:p 20': 0.38; 'thank': 0.38; 'why': 0.39; 'sure': 0.39; 'format': 0.39; 'does': 0.39; 'url:mail': 0.40; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'making': 0.62; 'different': 0.63; 'you.': 0.64; 'experts.': 0.66; 'experts': 0.70; 'away,': 0.84; 'etc,': 0.84; 'lying': 0.84; 'obvious,': 0.91; 'tied': 0.93; 'hands': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=8wqvkVY+SQx1y9cfF7mlCd6di4GXjK8ud8kCuTC9Z/o=; b=exS5aIZ16q2b/ogqkkve9Sq3OY/PmZfZWDJSr1dkpUayKYCTCQ1kbLsL9Xwd8QearO bJxf26rmK7qgC7DviXs+G3aJlOgRx51xnSP/Z2KYdtmf2+54XHa2IiPxjaunPdbhoy8d lDL4kGfueymHcxwjBYGyg6D9ywPOv815aDL/MtkP5V/Qz8XicQeYN9PedM2/kOczTIpw b3JlbHc4GdcY1miz2885PlWHGaryTsSNEZlyP94YEPxvp9XQQDcqhCEXjZBIhlz5/iIo PoFjTgzK/ZNMLPkvcxCZcFUVcNybN01icQfL/Lw8/+iKefRvUipaGumPf5FTW9Bfd/Q7 zKJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=8wqvkVY+SQx1y9cfF7mlCd6di4GXjK8ud8kCuTC9Z/o=; b=Ci4xX1I2QV1X+RCoPVEmtsxrzyOB6/GfOPkTxUc5x1vv7CaeAE1I4EbiAwVUc3Im6Z JAiB4WgxRLpkNpiPCBOX6Ac2k26qK6gAjw4J8uesrW6BBtU2CvgDpxFNdJQV81zh8g6/ OAnajEzNKZlHHGDM6pOPaXqDuUKkzfGADcz4P08V63XJc8emOpQDLy8BIkIqt0Z8dnHe N5DpIT4GEKL261uAKflfbfLqtDkuoi1kHTeJlErfiswdLANV8/7vJqtBk07QZS24eWQs ft0l9cDx3fbSfdWWb5wE33iDtfJ5o6CI2oclvMWUahF/pL3mYLSAF3EEXT46yYWy3d/G JCCw== X-Gm-Message-State: AEkooutihWbiPcB0BWPMNSCqXbxeTFd2hs2id5s8cK9tCET6AOyOfPLymx1S3dIp9KwQSvXkXVUTger0753Jrw== X-Received: by 10.31.51.6 with SMTP id z6mr30560621vkz.134.1470326973849; Thu, 04 Aug 2016 09:09:33 -0700 (PDT) In-Reply-To: <57a36593$0$1590$c3e8da3$5496439d@news.astraweb.com> 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: X-Mailman-Original-References: <710599b6-b8c3-4f5a-a3dd-48757b816a44@googlegroups.com> <57a36593$0$1590$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:112335 Steven, On Thu, Aug 4, 2016 at 11:56 AM, Steven D'Aprano wrote: > On Fri, 5 Aug 2016 01:31 am, GBANE FETIGUE wrote: > >> try: >> parsed_response =3D json.loads(response) >> deployid =3D parsed_response[u'id'] >> print "Your deployid is: " + deployid >> except: >> print 'Seems the named id already exists!' > > > I'm not going to try to debug your code blindfolded with my hands tied > behind my back. Get rid of those "try...except" blocks so that you can se= e > what error is *actually* happening. > > As you have it now, an error happens, somewhere. You don't know where the > error is, or what it is, but Python generates a nice exception showing al= l > the detail you need to debug. > > But you catch that exception, throw it away, and then print a lie. > > It is **not true** that the named ID already exists. That is not what the > error is, so why does your script tell a lie? > > The output from the server might give you a clue: > > "The server refused this request because the request entity is in a forma= t > not supported by the requested resource for the requested method." > > > Never[1] use a bare "try...except". It is the worst thing you can do to a > Python script, making it almost impossible to debug. > > https://realpython.com/blog/python/the-most-diabolical-python-antipattern= / > > Fix that problem first, get rid of the "try...except" and lying print > messages, and then either the bug will be obvious, or we can debug furthe= r. > > > > > > > [1] There are exceptions to this rule, for experts. But if you need to as= k > what they are, you're not ready to know But even the experts will never write such a code - you never know what hap= pens in a month. Server might throw some new exception, you may move on to a different project, etc, etc. ;-) Thank you. > > > -- > Steve > =E2=80=9CCheer up,=E2=80=9D they said, =E2=80=9Cthings could be worse.=E2= =80=9D So I cheered up, and sure > enough, things got worse. > > -- > https://mail.python.org/mailman/listinfo/python-list