[Zope-dev] Constant values defined in interfaces

Tres Seaver tseaver at palladion.com
Sun Apr 5 11:25:44 EDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris McDonough wrote:
> Using an interface class for a constant "container" would often be handy but it
> might be an inappropriate use of interface classes.  FTR, I do often put
> constants in an "interfaces.py" module at module scope (if there are more than
> one related, sometimes in a dictionary or within a non-interface class
> statement) in order to not feel I need to create some "constants.py" module.
> Maybe we could just agree that doing so isn't some sort of violation of intent?

If constants are part of the spec for an interface, then placing them at
module scope as peers of the interface seems fine to me.  In that case,
the docstrings of one or methods would presumably refer to them, e.g.
describing allowed valeus for an argument.

Using a "real" class as a container for them seems over-fancy for my taste.



Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJ2M14+gerLs4ltQ4RAlFtAJoC1a429B5HLcsdoMAlQ3ovjuBUjgCgyTlt
GiAEVR//SkkiMO60xn+fHvE=
=Mzb/
-----END PGP SIGNATURE-----



More information about the Zope-Dev mailing list