Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106244 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2016-04-01 11:25 -0600 |
| Last post | 2016-04-01 11:25 -0600 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [Python-ideas] Decorators for variables Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-01 11:25 -0600
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2016-04-01 11:25 -0600 |
| Subject | Re: [Python-ideas] Decorators for variables |
| Message-ID | <mailman.321.1459531585.28225.python-list@python.org> |
On Fri, Apr 1, 2016 at 11:14 AM, Matthias welp <boekewurm@gmail.com> wrote: >> An example of the transformation would help here > > An example, that detects cycles in a graph, and doesn't do an update if > the graph has cycles. Thanks. > class A(object): > def __init__(self, parent): > @prevent_cycles > self.parent = parent I think you'll find that this doesn't work. Properties are members of the class, not of instances of the class. > This would prevent cycles from being created in this object A, and would > make > some highly reusable code. The same can be done for @not_none, etc, to > prevent > some states which may be unwanted. But you could accomplish the same thing with "self.parent = prevent_cycles(parent)". So I'm still not seeing how the use of the decorator syntax eliminates repetition.
Back to top | Article view | comp.lang.python
csiph-web