Opened 9 years ago

Last modified 8 years ago

#6523 task new

— at Constants HOWTO doesn’t document that constants are ordered.Version 1

Reported by: Wilfredo Sánchez Vega Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Glyph, Wilfredo Sánchez Vega Branch:
Author:

Description (last modified by Wilfredo Sánchez Vega)

The ordered and comparable behavior of constants would be useful to document:

>>> from twisted.python.constants import NamedConstant, Names
>>> class Letters(Names):
...   a = NamedConstant()
...   b = NamedConstant()
...   c = NamedConstant()
... 
>>> Letters.a < Letters.b < Letters.c
True
>>> Letters.a > Letters.b 
False
>>> Letters.c < Letters.b < Letters.a
False
>>> Letters.c > Letters.b 
True
>>> sorted([Foos.b, Foos.a, Foos.c])
[<Foos=a>, <Foos=b>, <Foos=c>]
>>> 

Change History (1)

comment:1 Changed 9 years ago by Wilfredo Sánchez Vega

Description: modified (diff)
Note: See TracTickets for help on using tickets.