Opened 6 years ago

Closed 6 years ago

#5383 enhancement closed fixed (fixed)

Provide a library for simple valued named constants

Reported by: Jean-Paul Calderone Owned by: Jean-Paul Calderone
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch: branches/valued-constants-5383
branch-diff, diff-cov, branch-cov, buildbot
Author: exarkun

Description (last modified by Jean-Paul Calderone)

#4671 proposed adding a lot of new symbolic constant features to a helper somewhere in Twisted. This is for the kind of symbolic constant that has an associated value (perhaps unique? perhaps not? perhaps those are both valueable use cases), assigned either manually or automatically from a monotonically increasing sequences of integers.

This would be useful in the HTTP implementation, in the IRC implementation, in the telnet implementation, and probably in lots more places.

Change History (7)

comment:1 Changed 6 years ago by Jean-Paul Calderone

Description: modified (diff)

comment:2 Changed 6 years ago by Jean-Paul Calderone

Author: exarkun
Branch: branches/valued-constants-5383

(In [33282]) Branching to 'valued-constants-5383'

comment:3 Changed 6 years ago by Jean-Paul Calderone

Keywords: review added
Owner: Jean-Paul Calderone deleted

comment:4 Changed 6 years ago by Itamar Turner-Trauring

Owner: set to Itamar Turner-Trauring
Status: newassigned

comment:5 Changed 6 years ago by Itamar Turner-Trauring

Keywords: review removed
Owner: changed from Itamar Turner-Trauring to Jean-Paul Calderone
Status: assignednew
  1. _ConstantsContainer still has references to NamedConstants and Names. Likewise _EnumerantsInitializer.
  2. I'd move NamedConstant to be next to Names, rather than off elsewhere in the code.
  3. lookupByValue should document, and test, that if there are multiple constants with same value, the first one will be returned.

Once you fix those, feel free to merge.

comment:6 Changed 6 years ago by Jean-Paul Calderone

(In [33329]) document and test value constants with duplicate values

refs #5383

comment:7 Changed 6 years ago by Jean-Paul Calderone

Resolution: fixed
Status: newclosed

(In [33330]) Merge valued-constants-5383

Author: exarkun Reviewer: itamar Fixes: #5383

Add twisted.python.constants.Values, a utility for defining named constants with associated values.

Note: See TracTickets for help on using tickets.