annotate Demo/dns/dnsopcode.py @ 4566:6403c94de50d
legacy-trunk
Added safeguard against failure in __del__.
| author |
Guido van Rossum <guido@python.org> |
| date |
Wed, 27 Nov 1996 19:39:58 +0000 |
| parents |
78bf675df5e5 |
| children |
|
| rev |
line source |
|
1964
|
1 # Opcode values in message header (section 4.1.1)
|
|
|
2
|
|
|
3 QUERY = 0
|
|
|
4 IQUERY = 1
|
|
|
5 STATUS = 2
|
|
|
6
|
|
|
7 # Construct reverse mapping dictionary
|
|
|
8
|
|
|
9 _names = dir()
|
|
|
10 opcodemap = {}
|
|
|
11 for _name in _names:
|
|
|
12 if _name[0] != '_': opcodemap[eval(_name)] = _name
|
|
|
13
|
|
|
14 def opcodestr(opcode):
|
|
|
15 if opcodemap.has_key(opcode): return opcodemap[opcode]
|
|
|
16 else: return `opcode`
|