[Bf-committers] Decorator Pattern
ideasman42 at gmail.com
Mon Mar 12 14:44:38 CET 2018
Thanks for the correction.
You can wrap RNA instances in your own classes and pass them around.
>>> class MyDecorObject(bpy.types.Object):
... def my_prop(self):
... return "Foo"
>>> o = MyDecorObject(bpy.context.object)
But this isn't done anywhere in Blender AFAIK
On Mon, Mar 12, 2018 at 10:31 PM, Toni Alatalo <toni at playsign.net> wrote:
> Python decorators do not implement the Decorator Pattern, they are
> different things. Wikipedia explains it like this:
> """ https://en.wikipedia.org/wiki/Decorator_pattern#Python
> Please do not confuse the Decorator Pattern (or an implementation of
> this design pattern in Python - as the above example) with Python
> Decorators, a Python language feature. They are different things.
> Second to the Python Wiki:
> The Decorator Pattern is a pattern described in the Design Patterns
> Book. It is a way of apparently modifying an object's behavior, by
> enclosing it inside a decorating object with a similar interface. This
> is not to be confused with Python Decorators, which is a language
> feature for dynamically modifying a function or class."""
> I'm not surprised if that pattern, nor other from the OO patterns
> movement, is not used in Blender at all. Curious to hear if it is,
> though :)
> On Mon, Mar 12, 2018 at 7:25 AM, Campbell Barton <ideasman42 at gmail.com> wrote:
>> Hi, Blender's built in scripts don't make much use of decorators
>> they are used here though:
>> On Mon, Mar 12, 2018 at 11:33 AM, Brad Eric hollister
>> <behollis at soe.ucsc.edu> wrote:
>>> I’m preparing a short talk on the decorator pattern for classroom instruction.
>>> I’d like to use an example from Blender. Are there any such examples in the codebase?
>>> Bf-committers mailing list
>>> Bf-committers at blender.org
>> - Campbell
>> Bf-committers mailing list
>> Bf-committers at blender.org
> Bf-committers mailing list
> Bf-committers at blender.org
More information about the Bf-committers