[Python-Dev] constant/enum type in stdlib (original) (raw)

Ron Adam rrr at ronadam.com
Tue Nov 30 00:38:26 CET 2010


On 11/28/2010 09:03 PM, Ron Adam wrote:

It does associate additional info to names and creates a nice dictionary to reference.

>>> def namevalues( FOO: 1, BAR: "Hello World!", BAZ: dict(a=1, b=2, c=3) ): ... return FOO, BAR, BAZ ... >>> foo(1,2,3) (1, 2, 3) >>> foo.annotations {'BAR': 'Hello World!', 'FOO': 1, 'BAZ': {'a': 1, 'c': 3, 'b': 2}}

sigh... I havn't been very focused lately. That should have been:

def named_values(FOO:1, BAR:"Hello World!", BAZ:dict(a=1, b=2, c=3)): ... return FOO, BAR, BAZ ... named_values.annotations {'BAR': 'Hello World!', 'FOO': 1, 'BAZ': {'a': 1, 'c': 3, 'b': 2}} named_values(1, 2, 3) (1, 2, 3)

Cheers, Ron



More information about the Python-Dev mailing list