On Sun, Nov 14, 2010 at 11:00 AM, Micah Carrick <mi...@greentackle.com> wrote:
> I'm writing a little API that other people will use. There are up to 3
> "objects" that get passed around. One of them has some validation methods,
> the other two simply store data and probably won't have any validation or
> other methods. I only made them objects so that they are syntactically (is
> that a word?) similar the other object rather than using dictionaries. I
> figure it also better allows for changes in the future.
>
> Any thoughts on the pros/cons of using my own objects over a dictionary
> objects?

Objects are definitely nicer to work with syntactically, and they help
make your program's types more explicit.
Rather than coding the "data holder" classes manually, consider using
namedtuples instead:
http://docs.python.org/library/collections.html#collections.namedtuple

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to