Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Vincent Vande Vyvre Newsgroups: comp.lang.python Subject: AttributeError into a bloc try-except AttributeError Date: Sun, 12 Jun 2016 09:20:44 +0200 Lines: 38 Message-ID: References: <9e7b6ded-15ad-490a-9842-b3da5d8a048d@googlegroups.com> <575D0D4C.5080106@telenet.be> Reply-To: vincent.vandevyvre@oqapy.eu Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de FcWWfIkhBEnlJp7LWo2OSQqfzQMH5t3YLGlSu2i5n42Q== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.040 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'subject:into': 0.09; 'python': 0.10; 'def': 0.13; 'from:name:vincent vande vyvre': 0.16; 'received:195.130': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'received:telenet-ops.be': 0.16; 'attribute': 0.18; 'module,': 0.18; 'try:': 0.18; '>>>': 0.20; 'code.': 0.23; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'linux': 0.26; 'behaviour': 0.29; 'code:': 0.29; 'handled': 0.29; 'received:be': 0.30; 'traceback': 0.33; 'file': 0.34; 'except': 0.34; 'skip:" 50': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'two': 0.37; 'skip:s 50': 0.37; 'hi,': 0.38; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'charset:windows-1252': 0.62; 'strange': 0.63; 'subject:skip:A 10': 0.63; 'more': 0.63; 'header :Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'video,': 0.79; 'subject:try': 0.84 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: <9e7b6ded-15ad-490a-9842-b3da5d8a048d@googlegroups.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: <575D0D4C.5080106@telenet.be> X-Mailman-Original-References: <9e7b6ded-15ad-490a-9842-b3da5d8a048d@googlegroups.com> Xref: csiph.com comp.lang.python:109843 Hi, I have a strange behaviour in my code. In an interactive session, the result is as expected: Python 3.4.3 (default, Oct 14 2015, 20:28:29) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> a = None >>> try: ... _ = a.value ... except AttributeError: ... print('OK') ... OK >>> But not in my code: def call_settings_dialog(self): try: _ = self.video.category self.core.artelive.configure_downloading(self.video) except AttributeError: self.core.artetv.configure_downloading(self.video) and ... Traceback (most recent call last): File "/home/vincent/qarte-3/trunk/loadingscheduler.py", line 240, in call_settings_dialog _ = self.video.category AttributeError: 'TVItem' object has no attribute 'category' I have two types of video, one with an attribute category handled by a module 'artelive' and an other without this attribute handled by an other module, that's the reason of this code.