File: case.py

package info (click to toggle)
metakit 2.4.3-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,468 kB
  • ctags: 3,548
  • sloc: xml: 29,455; cpp: 23,339; sh: 9,051; tcl: 1,195; python: 577; makefile: 254; ansic: 14
file content (32 lines) | stat: -rw-r--r-- 980 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Properties are case-insensitive, but this can lead to some
# surprising behavior: the first way a property is used will
# determine how it ends up in the global symbol table.
#
# Sample output:
#   Property('S', 'HeLLo') Property('S', 'HeLLo')
#   2
#   2
#   135099576
#   135033272
#   0

import metakit
db = metakit.storage()
v1 = db.getas('lo[HeLLo:S]')
v2 = db.getas('hi[hello:S]')

# surprise: this prints two mixed-case names
print v1.HeLLo, v2.hello

# this shows that the MetaKit property is the same for both
# reason: there is a single global case-insensitive symbol table
print metakit.property('S','HeLLo').id
print metakit.property('S','hello').id

# this shows that the Python objects differ
# reason: these are two wrapper objects around the same thing
print id(metakit.property('S','HeLLo'))
print id(metakit.property('S','hello'))

# this causes a mismatch, it will have to be fixed one day
print metakit.property('S','HeLLo') == metakit.property('S','hello')