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


Groups > comp.lang.python > #28943

Re: generators as decorators simple issue

From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Subject Re: generators as decorators simple issue
Date 2012-09-12 11:47 +0100
References <e738542a-f864-4ad0-9aaa-738047356841@googlegroups.com> <3ffa457e-7836-46d0-8246-03b6bd90a025@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.547.1347446843.27098.python-list@python.org> (permalink)

Show all headers | 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