metaclass
How to auto register a class when it's defined
I want to have an instance of class registered when the class is defined.Ideally the code below would do the trick.[详细]
2023-02-14 22:15 分类:问答Python, Zope Component Architecture, Registering an adapter
In a stand-alone python application I use zope.interface, zope.component packages to register and access application\'s adapters.[详细]
2023-02-12 12:32 分类:问答distinct classes using `with` in Python
If you have the following class: class Foo(object): def __init__(name): self.name = name And you use it like this in a file called check_foo.py[详细]
2023-02-11 00:36 分类:问答Ways to make a class immutable in Python
I\'m doing some distributed computing in which several machines communicate under the assumption that they all have identical versions of various classes. Thus, it seems to be good design to make thes[详细]
2023-02-10 05:40 分类:问答creating Python classes with arbitrarily substituted attribute name
I apologize for not giving this question a better title; the reason that I am posting it is that I don\'t even have the correct terminology to know what I am looking for.[详细]
2023-02-10 02:08 分类:问答Decorating a class method after @property
I want to wrap every method of various objects except __init__ using a decorator. class MyObject(object):[详细]
2023-02-08 20:43 分类:问答meta programming XMLSlurper results
I\'ve Slurped up a twitter feed where each entry looks like: <entry> <id>tag:search.twitter.com,2005:30481912300568576</id>[详细]
2023-02-07 09:16 分类:问答How To Mock Out A Closure In Order To Test The Grails Service Result?
I want to unit test the return value of some code which looks similar to this: Groovy Service code to test:[详细]
2023-02-05 09:33 分类:问答Automatic class decoration (or validation) upon derivation
I have a base class from which I derive multiple subcl开发者_开发知识库asses. Each subclass defines class constants, and I wish to enforce certain limitations on them.[详细]
2023-01-31 23:15 分类:问答How to read class attributes in the same order as declared?
I am writing a metaclass that reads class attributes and store them in a list, but I want the list (cls.columns) to respect the declaration order (that is: mycol2, mycol3, zut, cool, menfin, a in my e[详细]
2023-01-30 16:51 分类:问答