[Python-Dev] Enums and data retrieval

Antoine Pitrou solipsis at pitrou.net
Mon Apr 29 10:55:54 CEST 2013


Le Mon, 29 Apr 2013 00:13:53 -0700,
Ethan Furman <ethan at stoneleaf.us> a écrit :

> [starting new thread to not pollute the summary thread]
> 
> On 04/28/2013 11:54 PM, Antoine Pitrou wrote:> On Sun, 28 Apr 2013
> 17:29:35 -0700
> > Ethan Furman <ethan at stoneleaf.us> wrote:
> >>
> >> Not only is this inconsistent with the rest of Python*, but it's
> >> going to be a PITA for data storage/retrieval:
> >>
> >>       datastore = dbf.Table('storage.dbf', 'event_name C(50); date
> >> D; season SEASON')
> >>
> >>       def retrieve_record(...):
> >>           result = []
> >>           for field_type, field_data in record:
> >>               result.append(field_type(field_data))
> >
> > I've never seen any kind of "data retrieval" which works like that.
> > Would you care to explain us the context?
> 
> The more specific context would be my dbf package, which works with
> dBase III, Clipper, and Foxpro tables.  When the fields of a record
> are requested they are transformed into Python data types, with code
> that looks pretty much like that retrieve_record snippet (w/o all the
> error checks, etc.).  And no, it doesn't support enumerations (yet).

Hmm, ok. So the context is the database adapter itself, right? I
wouldn't be shocked for a database adapter to have specific code to
handle various datatypes. My point was that this kind of code generally
doesn't leak into application code.

That said, I agree that the general constructor syntax should be
allowed on Enum instances. The inconsistency looks a bit gratuitous.

Regards

Antoine.




More information about the Python-Dev mailing list