On Thu, May 22, 2008 at 12:21 AM, Brandon Mintern <<a href="mailto:bmintern@gmail.com">bmintern@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I would like to propose to change the built-in function "object" to<br>
have the following syntax:<br>
<br>
object(**kwargs)<br>
Return a new featureless object. object is a base for all new style<br>
classes. It has the methods that are common to all instances of new<br>
style classes.<br>
<br></blockquote></div><br>I agree this is a useful pattern. One thing I don't like about it is that:<br>   object(x=1, y=2)<br>looks very much like<br>   object(x=1, y=2, z=3)<br>and I probably won't discover I've been given the wrong one until it's too late. <br>
<br>I think it can better addressed by implementing NamedList and NamedDict:<br><br>NamedList(typename, fieldnames[, optionalfields[, verbose]])<br><br>Returns a new list subclass named typename. The new subclass is used to create list-like objects that have fields accessible by attribute lookup as well as supporting other list operations. Instances of a NamedList may be created using a mixture of positional and keyword arguments. If optionalfields is not true, then the NamedList must always contain at least as many elements as the number of fields. If the NamedDict contains fewer elements than the number of fields, missing fields return None when accessed by attribute (a.third) and raise IndexError when accessed by index (a[3]).<br>
<br>NamedDict(typename, fieldnames[, optionalfields[, verbose]])<br><br>
Returns a new dict subclass named typename. The new subclass is used to
create dict-like objects that have fields accessible by attribute
lookup as well as supporting other dict operations. Instances of a NamedDict may be created using keyword arguments only. If optionalfields is not true, then the NamedDict must have a value for every field. If a NamedDict does not contain a field, accessing it returns None when
accessed by attribute (a.x) and raises KeyError when accessed using by key (a['x']). <br><br>--- Bruce<br>