<br><div class="gmail_quote">On Sun, Nov 14, 2010 at 11:20 AM, Chris Rebert <span dir="ltr"><<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Sun, Nov 14, 2010 at 11:00 AM, Micah Carrick <<a href="mailto:micah@greentackle.com">micah@greentackle.com</a>> wrote:<br>
> I'm writing a little API that other people will use. There are up to 3<br>
> "objects" that get passed around. One of them has some validation methods,<br>
> the other two simply store data and probably won't have any validation or<br>
> other methods. I only made them objects so that they are syntactically (is<br>
> that a word?) similar the other object rather than using dictionaries. I<br>
> figure it also better allows for changes in the future.<br>
><br>
> Any thoughts on the pros/cons of using my own objects over a dictionary<br>
> objects?<br>
<br>
</div>Objects are definitely nicer to work with syntactically, and they help<br>
make your program's types more explicit.<br>
Rather than coding the "data holder" classes manually, consider using<br>
namedtuples instead:<br>
<a href="http://docs.python.org/library/collections.html#collections.namedtuple" target="_blank">http://docs.python.org/library/collections.html#collections.namedtuple</a><br></blockquote><div><br>namedtuples are nice, but I don't think pylint understands how to look inside them as well as it understands how to look inside class instances.<br>
<br>pylint isn't for everyone, but I find it very useful in producing sturdy python code with few surprises at runtime.<br> <br></div></div>