Unnamed
public text v1 · immutable>>> import re
>>> re.compile("(HP\s*(?P<curhp>[0-9]+)/(?P<maxhp>[0-9]+))")
<_sre.SRE_Pattern object at 0xb76576b0>
>>> a=re.compile("(HP\s*(?P<curhp>[0-9]+)/(?P<maxhp>[0-9]+))")
>>> c=a.match("HP 10/10")
>>> class Player (object):
... def __init__ (self, match):
... self.__dict__.update(match.groupdict())
...
>>> Player(c)
<__main__.Player object at 0x87b2aac>
>>> b=Player(c)
>>> b
<__main__.Player object at 0x87b2e6c>
>>> b.curhp
'10'
>>>