File: register.py

package info (click to toggle)
python-phx-class-registry 4.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 260 kB
  • sloc: python: 886; makefile: 19
file content (17 lines) | stat: -rw-r--r-- 318 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from class_registry import ClassRegistry

pokedex = ClassRegistry()

@pokedex.register('fire')
class Charizard(object):
    pass

@pokedex.register('grass')
class Bulbasaur(object):
    pass

fighter1 = pokedex['fire']
assert type(fighter1) is Charizard

fighter2 = pokedex['grass']
assert type(fighter2) is Bulbasaur