Re: [Python-ideas] Proposal to add new built-in struct (was: Add kwargs to built-in function object)

On Thu, May 22, 2008 at 6:25 PM, Matthew Russell <matt.horizon5@gmail.com> wrote:
I've used the name "Record" in the past, but when I was trying to figure out if Python had anything like a C struct, I searched specifically for "python struct". I'm not sure how many others do the same, but perhaps using a name like "structure" would be better than "record"? (On a side note, see what I mean about the work involved in naming a class? :-)
I'm guessing that the last line was meant to be "return Record(**kwargs)"
I can see where you're coming from, but this change would mean that you would no longer be able to inherit from record (or structure, or whatever). Also, if you're making that many changes to the class, it wouldn't be too hard to rewrite the initial instantiation to not use positional parameters with or without kwargs (after rewriting the constructor, which you would clearly be doing, anyways). Another caveat is that each call to record() will create an object of a different class. Thus, if you have the following: employees = {} for ssn, fn, ln in employee_data_list: employees[ssn] = record(ssn=ssn, first=fn, last=ln) Then employees[ssn1].__class__ != employees[ssn2].__class__. This seems like it could be an issue at some point. Brandon
participants (1)
-
Brandon Mintern