using names before they're defined

davehowey at f2s.com davehowey at f2s.com
Wed Jul 19 12:41:31 EDT 2006


> Even if you need to do something during attachment of components it is
> more Pythonic to use properties. So you will write a method in your
> class name something like _set_up(self,upstream_obj) an  _get_up(self).
>  And then at the end of your class put up=property(_get_up, _set_up).
> You can still use the compr.up=... format.

sorry, I don't quite follow. what are properties?

> Also, you might want to re-think your OO design. It seem that all of
> your components do a lot of things in common already. For one they all
> are connected to other components like themselves, they also propably
> will have method to do some computing, perhaps send or receive stuff
> from other components, or they all will implement somekind of an event
> model. In that case you could create a generic component class and
> sublass the specific implementations from it.

yes, I already do this - I have a component class and then the other
components inherit from it.

Dave




More information about the Python-list mailing list