[Python-Dev] from tuples to immutable dicts

Brett Cannon bac@OCF.Berkeley.EDU
Sat, 23 Nov 2002 16:55:44 -0800 (PST)

[Martin v. Loewis]

> Fred once had a plan to expose structseqs to Python, to allow the
> creation of new structs in Python. I was suggesting that there should
> be a method new.struct_seq, which is called as
> struct_seq(name, doc, n_in_sequence, (fields))
> where fields is a list of (name,doc) tuples. The resulting thing would
> be similar to os.stat_result: you need to call it with the mandatory
You meant "can", right, Martin?

> fields in sequence, and can call it with the optional fields by
> keyword argument.

I think the idea is good if you can get it to tie directly into C code.
That would get a +1 from me.  If not, then +0.  Kind of strikes me like a
poor man's object with __getitem__ written to call the object's attributes
assigned a numeric name.  Or can be viewed as a tuple with attribute names
for each index.

If my Perl memory is not too rusty then I think this would be like Perl's
arrays which might help get more people over from Perl (if we really want
that =).