__slots__, setattr, __metaclass__

Discussion in 'Python' started by Roman Yakovenko, Jan 12, 2004.

  1. 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.
    Roman Yakovenko, Jan 12, 2004
    1. Advertisements

  2. I think you may be interested in this recipe:


    (uses setattr, metaclasses, no slots).

    Michele Simionato, Jan 12, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.