Ticket #80 (closed defect: wontfix)

Opened 5 months ago

Last modified 5 months ago

yaml.load doesn't work as i suspect it to according to the documentation

Reported by: anonymous Assigned to: xi
Priority: normal Component: pyyaml
Severity: normal Keywords:
Cc:

Description

quote from the documentation:

>>> class Monster(yaml.YAMLObject):
...     yaml_tag = u'!Monster'
...     def __init__(self, name, hp, ac, attacks):
...         self.name = name
...         self.hp = hp
...         self.ac = ac
...         self.attacks = attacks
...     def __repr__(self):
...         return "%s(name=%r, hp=%r, ac=%r, attacks=%r)" % (
...             self.__class__.__name__, self.name, self.hp, self.ac, self.attacks)

>>> yaml.load("""
... --- !Monster
... name: Cave spider
... hp: [2,6]    # 2d6
... ac: 16
... attacks: [BITE, HURT]
... """)

the thing is, yaml.load ignores the __init__ method of the Monster class. it doesn't even matter if it's there at all. in yaml.load you can specify aditional variables and they get added to the object. intended behaviour?

Attachments

Change History

05/26/08 03:19:06 changed by xi

  • status changed from new to closed.
  • resolution set to wontfix.

Duplicate of #48, see my comment there.

05/26/08 08:07:34 changed by anonymous

maybe it would be best then to mention it in the documentation to prevent others like me wondering what's goind wrong :) because i think the line

Monster(name='Cave spider', hp=[2, 6], ac=16, attacks=['BITE', 'HURT'])

that is printed as a representation of the loaded object in the documentation is a bit misleading as it's not actually what get's called apparently


Add/Change #80 (yaml.load doesn't work as i suspect it to according to the documentation)




Change Properties
Action