Module level descriptors or properties
Diez B. Roggisch
deets at nospam.web.de
Tue Aug 21 09:46:33 EDT 2007
Floris Bruynooghe wrote:
> Hi
>
> When in a new-style class you can easily transform attributes into
> descriptors using the property() builtin. However there seems to be
> no way to achieve something similar on the module level, i.e. if
> there's a "version" attribute on the module, the only way to change
> that to some computation later is by using a getter from the start as
> your public API. This seems ugly to me.
>
> Does anyone know of a better way to handle this?
Not really. All you can do is proxy all the calls through an actual object,
most probably a singleton.
Diez
More information about the Python-list
mailing list