__slots__, setattr, __metaclass__

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roman Yakovenko

    __slots__, setattr, __metaclass__

    Hi. I have small problem and I don't know solution.
    The problem: every class imported from some module X should not allow to be modified
    ( modified == adding or deleting new class attributes ).
    Small explanation about what I am doing: I has complex dll written in Managed C++ for C#.
    I am using "Python for .NET" and python unittest module to test my dll.
    I find myself often make a mistake in attributes names. I'd like to protect my self from those errors.
    In subject I listed available options, but I don't know which one to pick and how to use it in my situation.

    As you can guess I can't to modify Managed C++ sources.

    Thanks. Roman.


  • Michele Simionato

    #2
    Re: slots , setattr, metaclass

    "Roman Yakovenko" <roman.yakovenk o@actimize.com> wrote in message news:<mailman.2 87.1073894630.1 2720.python-list@python.org >...[color=blue]
    > Hi. I have small problem and I don't know solution.
    > The problem: every class imported from some module X should not allow to
    > be modified
    > ( modified == adding or deleting new class attributes ).[/color]

    I think you may be interested in this recipe:



    (uses setattr, metaclasses, no slots).


    Michele

    Comment

    Working...