[issue2502] Add enum() example for named tuples

2008-03-29 Thread Raymond Hettinger
Raymond Hettinger <[EMAIL PROTECTED]> added the comment: Thanks for asking. This should not go into the collections module. The concept makes more sense in statically compiled languages. In Python, we typically write something like "RED, ORANGE, YELLOW = range (3)" at the module level. That i

[issue2502] Add enum() example for named tuples

2008-03-28 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: Raymond, is this kind of recipes worth adding to the 'collections' module? Maybe with the following form: def enum(*valuenames): return namedtuple('Enum', valuenames)(*range(len(valuenames))) -- nosy: +amaury.forgeotdarc,

[issue2502] Add enum() example for named tuples

2008-03-28 Thread Georg Brandl
Georg Brandl <[EMAIL PROTECTED]> added the comment: Fixed example (a * was missing) and committed as r62007. Thanks! -- resolution: -> accepted status: open -> closed __ Tracker <[EMAIL PROTECTED]> _

[issue2502] Add enum() example for named tuples

2008-03-28 Thread Wummel
Wummel <[EMAIL PROTECTED]> added the comment: The motivation for this patch is that documenting a single function adding enum-like capabilities would hopefully eliminate the numerous "enum" recipies already out there, each handling things a little different. __ Tr

[issue2502] Add enum() example for named tuples

2008-03-28 Thread Wummel
New submission from Wummel <[EMAIL PROTECTED]>: Named tuples can also be used to emulate enum datatypes. The patch adds an example to the documentation. -- assignee: georg.brandl components: Documentation files: 0001-Add-enum-example-for-named-tuples.patch keywords: patch messages: 64627