How to implement class/object metadata in Python? -
i working on structured data analysis framework based on streaming data between nodes. nodes implemented subclasses of root node class provided framework. each node class/factory need metadata, such list of node's attributes, description, node output. metadata might both: end-users in front-end application or programming use - other stream management tools. in future there more of them.
(note started learn python while writing code)
currently metadata provided in class variable
class aggregatenode(base.node): """aggregate""" __node_info__ = { "label" : "aggregate node", "description" : "aggregate values grouping key fields.", "output" : "key fields followed aggregations each aggregated field. last field " "record count.", "attributes" : [ { "name": "keys", "description": "list of fields according records grouped" }, { "name": "record_count_field", "description": "name of field record count stored. " "default `record_count`" } ] }
more examples can found here.
i feel can done in cleaner way. there 1 restriction: nodes custom subclasses classes, there should minimal interference potential future attribute names.
what thinking split current node_info. meant private framework, realize has wider use. thinking using node_ attributes: have common attribute namespace, not taking of names potential custom node attributes.
my question is: common way of providing such metadata in python programs? single variable dictionary? multiple variables, 1 each metadata attribute? (this conflict restriction) custom class/structure? use kind of prefix, node_* , use multiple variables?
i'm not sure if there "standard" way store custom metadata in python objects, example, python implementation of dbus adds attributes "_dbus
" prefix published methods , signals.
Comments
Post a Comment