Enums and data retrieval

[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
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~

Le Mon, 29 Apr 2013 00:13:53 -0700, Ethan Furman <ethan@stoneleaf.us> a écrit :
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.

Le Mon, 29 Apr 2013 00:13:53 -0700, Ethan Furman <ethan@stoneleaf.us> a écrit :
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.
participants (2)
-
Antoine Pitrou
-
Ethan Furman