Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28943

Re: generators as decorators simple issue

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 <python-python-list@m.gmane.org>
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 <oscar.j.benjamin@gmail.com>
Subject Re: generators as decorators simple issue
Date Wed, 12 Sep 2012 11:47:02 +0100
References <e738542a-f864-4ad0-9aaa-738047356841@googlegroups.com> <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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.547.1347446843.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Wed, 12 Sep 2012 03:22:31 -0700 (PDT), pyjoshsys 
<j.m.dagenhart@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

generators as decorators simple issue j.m.dagenhart@gmail.com - 2012-09-11 19:28 -0700
  Re: generators as decorators simple issue Ramchandra Apte <maniandram01@gmail.com> - 2012-09-11 19:55 -0700
  Re: generators as decorators simple issue alex23 <wuwei23@gmail.com> - 2012-09-11 21:39 -0700
  Re: generators as decorators simple issue Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-09-12 08:08 +0200
  Re: generators as decorators simple issue pyjoshsys <j.m.dagenhart@gmail.com> - 2012-09-12 03:22 -0700
    Re: generators as decorators simple issue Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-09-12 11:47 +0100
    Re: generators as decorators simple issue Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-12 09:09 -0600
  Re: generators as decorators simple issue pyjoshsys <j.m.dagenhart@gmail.com> - 2012-09-12 04:15 -0700

csiph-web