[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 is faster and still allows prefixing 
using the module name (for example, re.MULTILINE).

--
resolution: accepted - rejected

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2502
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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
nosy: calvin, georg.brandl
severity: normal
status: open
title: Add enum() example for named tuples
versions: Python 2.6
Added file: 
http://bugs.python.org/file9881/0001-Add-enum-example-for-named-tuples.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2502
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2502
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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]
http://bugs.python.org/issue2502
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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, rhettinger

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2502
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com