[Python-Dev] Enums and data retrieval (original) (raw)
Ethan Furman ethan at stoneleaf.us
Mon Apr 29 09:13:53 CEST 2013
- Previous message: [Python-Dev] enum discussion: can someone please summarize open issues?
- Next message: [Python-Dev] Enums and data retrieval
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[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', 'eventname C(50); date D; season SEASON') def retrieverecord(...): result = [] for fieldtype, fielddata in record: result.append(fieldtype(fielddata)) 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).
A more general context would be anywhere that you need to convert the integer offset of an enum item back into the enum
item itself; you may have gotten the integer offset from a postgres database, or an RPC call, and it seems to me the
natural way get the enum item from that is with EnumClass(offset).
--
Ethan
- Previous message: [Python-Dev] enum discussion: can someone please summarize open issues?
- Next message: [Python-Dev] Enums and data retrieval
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]