Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'output': 0.04; 'attribute': 0.05; 'finally:': 0.05; 'line:': 0.07; 'try:': 0.07; 'hiding': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runtime': 0.09; 'sep': 0.09; 'def': 0.10; 'cls': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:issue': 0.16; 'subject:simple': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'proposed': 0.20; 'demonstrate': 0.23; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'charset:iso-8859-15': 0.26; 'header:X-Complaints-To:1': 0.28; 'skip:_ 10': 0.29; 'class': 0.29; 'function': 0.30; 'error': 0.30; 'print': 0.32; 'to:addr:python-list': 0.33; 'received:org': 0.36; 'except': 0.36; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'remove': 0.61; 'oscar': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Oscar Benjamin Subject: Re: generators as decorators simple issue Date: Wed, 12 Sep 2012 11:47:02 +0100 References: <3ffa457e-7836-46d0-8246-03b6bd90a025@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: cpc1-aztw8-0-0-cust1455.18-1.cable.virginmedia.com In-Reply-To: <3ffa457e-7836-46d0-8246-03b6bd90a025@googlegroups.com> User-Agent: Groundhog Newsreader for Android 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347446843 news.xs4all.nl 6968 [2001:888:2000:d::a6]:54170 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28943 On Wed, 12 Sep 2012 03:22:31 -0700 (PDT), pyjoshsys wrote: > The output is still not what I want. Now runtime error free, however the output is not what I desire. > def setname(cls): > '''this is the proposed generator to call SetName on the object''' > try: > cls.SetName(cls.__name__) > except Exception as e: > print e > finally: > return cls I would write the function above in one line: cls.name = name > class Trial(object): > '''class to demonstrate with''' > def __init__(self): > object.__init__(self) > self.name = None Remove the line above. The instance attribute self.name is hiding the class attribute cls.name. Oscar