Initializing something in compute and checking it later every time compute is called is just wrong. The whole purpose of the dependency graph is to maintain efficient [lazy] evaluation of the network. For that reason, I personally would not put such a check into compute. If the node is part of some larger system then I'd build this initialization into the system. For instance, we have a basic nodetype that we hang a lot of data off of. If the node is created with the standard 'createNode' then there is no unique data on that node. It is incumbent on the system to format the node upon creation so that the node has meaning to the system. We have an api that facilitates node creation and manipulation, such as connection management, querying, etc., that wraps all of the core maya calls, and does all of our specific handling. It's a data driven system that uses an xml file to describe the structure of the data that should appear on each of the nodes.We also register a number of callbacks for these nodes when they are created, as Chad Vernon mentions. If the node is not part of a larger system then you may not have the code infrastructure in place that wold allow you to do this sort of thing easily. I would still consider wrapping the creation call into a special purpose call designed to set this node up properly. I know initializing the attribute values in this way isn't perhaps as cool or tidy, but it will keep the dg running efficiently.
A couple of questions come to mind: Who is going to be creating this node? When will the node be created?
--
http://groups.google.com/group/python_inside_maya