New to python

inhahe inhahe at gmail.com
Mon Nov 30 12:14:04 EST 2009


to put it simplistically it's a way of combining multiple variables into one
for example, for a person you could have

person.haircolor
person.echnicity
person.age
etc.

but you can then also manipulate 'person' as a whole like you would
any other variable, such as
x[n] = person

a struct, as far as i know, is like a class but with no methods.  or a
class is like a struct but with methods that act on the struct's data.

i don't think structs technically exist in Python (though they exist
in C/C++), but you could always use a plain class like a struct, like
this, for a simple example:

class Blah:
  pass

b = blah()
b.eyecolor = "brown"
b.haircolor = "blond"
b.ethnicity = "caucasion"

On Mon, Nov 30, 2009 at 11:20 AM, Ronn Ross <ronn.ross at gmail.com> wrote:
> I have recently come across something called a struct. I have googled this,
> but have note found a good explanation. Can someone give me a good
> definition or point me to a page that has one.
>
> Thanks
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



More information about the Python-list mailing list