Simulation in Python, C enumeration type

Back to the index can be used enumerate the characteristics to generate the dictionary to model c of the enumerated type.

>>> print dict([(element, index) for index, element in enumerate(('SUCCESS', 'FAIL', 'EXCEPTION'))])
{'FAIL': 1, 'EXCEPTION': 2, 'SUCCESS': 0}

This was the advantage, you can manually save the definition of value of work.

分类:Python 时间:2010-06-11 人气:159
分享到:
blog comments powered by Disqus

相关文章

  • Complicated enumeration, if you use a single case of mode, you can use only one element of the enumeration 2010-06-16

    Wrote, package com.css.aopframework; / ** * More complicated enumeration, if you use a single case of mode, you can use only one element of the enumeration * @ Author Administrator * * / public enum WeekDayEnum ( SUN (30) ( public WeekDayEnum nextDay

  • Lucene 4.X 倒排索引原理与实现: (3) Term Dictionary和Index文件 (FST详细解析) 2014-10-31

    我们来看最复杂的部分,就是Term Dictionary和Term Index文件,Term Dictionary文件的后缀名为tim,Term Index文件的后缀名是tip,格式如图所示。 Term Dictionary文件首先是一个Header,接下来是PostingsHeader,这两个的格式一致,但是保存的是不同的信息。SkipInterval是跳跃表的跳的幅度,MaxSkipLevels是跳跃表的层数,SkipMinimun是应用跳跃表的最小倒排表长度,接下来就是Term的部分了。

  • Log in and submit the form python simulation 2010-07-09

    This article will get content from a blog posted to the CSDN Baidu blog, blog content, respectively crawl practice, simulated log, the form submission. Code below the middle one by one. # -*- coding: utf-8 -*- import re import urllib import urllib2 import

  • python design model - behavior 2011-01-12

    Vistor mode: Vistor pattern is often used to access the data, different data support the incoming visitor (or processor), on the example of def visit(directory, visitor): for root, dirs, files in os.walk(directory): for f in files: ext = os.path.spli

  • Python simulation JAVA AOP 2011-05-04

    from time import ctime,sleep; def testFunction(func): def wrapFunction(): print "call func on %s,funcName is %s" % (ctime(),func.__name__); return func(); return wrapFunction; @testFunction def foo(): print "foo is called on %s" % (ctime()); #print 123; d

  • Simulation in Python, C, enumerated types 2010-06-11

    Back to the index can be used enumerate the characteristics to generate the dictionary to model c of the enumerated type. >>> print dict([(element, index) for index, element in enumerate(('SUCCESS', 'FAIL', 'EXCEPTION'))]) {'FAIL': 1, 'EXCEP

  • Python objects into xml 2010-04-20

    # -*- coding:UTF-8 -*- ''' Created on 2010-4-20 @author: Sad Fabricius ''' import xml.etree.ElementTree as ET import xml.dom.minidom as minidom from addrbook.domain import Person class Converter(object): ''' Implements the Python objects and xml Conversio

  • Some Python programming article online 2010-09-01

    newthreading - safer concurrency for Python security concurrency (1 response) http://www.starming.com/index.php?action=plugin&v=wave&tpl=union&ac=viewgrouppost&gid=73&tid=7607 Several Google App Engine open source program http://www.st

  • [Information retrieval] Introduce to IR (1): Boolean retrieval model 2010-03-18

    The series is "An Introduce to Information Retrieval" Chapter 1 of the study notes. The concept of IR is very broad, even took out a credit card from the wallet and enter the card number is also a form of information retrieval. In the academic f

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.124 (s). 14 q(s)