Ben Finney bignose+hates-spam at
Mon Nov 3 22:45:13 CET 2008

"Paulo J. Matos" <pocmatos at> writes:

> On Mon, Nov 3, 2008 at 12:32 PM, Ben Finney
> <bignose+hates-spam at> wrote:
> > I'm wondering a more fundamental question: What are structures?
> > That is, what do *you* mean by that term; without knowing that, an
> > answer isn't likely to be meaningful.
> Well, I guess that everyone pretty much gets since it exists in
> every other language as struct, or define-structure, or whatever is
> the syntax.

Take care with broad sweeping statements about “every other language”,
or even “most other languages”. They are usually flat-out wrong:
there is a stunning variety of different approaches and concepts in
programming languages, with very little common to even a majority of

So no, the question was entirely honest and not a rhetorical device.

> Still, answering your rhetoric question, a structure is way to
> gather information by fields and those fields are referenced by
> name.

Okay, you're talking about ‘struct’ from the C language. That helps
answer the question.

In Python, the way to do that is with a dict. A class can be used, but
is often overkill if one doesn't need customised behaviour.

> The fact that python 2.6 has now named tuples is a breath of fresh
> air!

That works also, but a dict will be more broadly useful; and
compatible with any Python version.

 \     “Creativity can be a social contribution, but only in so far as |
  `\            society is free to use the results.” —Richard Stallman |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list