You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Philip Zeyliger (JIRA)" <ji...@apache.org> on 2009/07/22 20:01:14 UTC
[jira] Commented: (THRIFT-546) Python generated code should give
the ability to convert to/from string names of enums
[ https://issues.apache.org/jira/browse/THRIFT-546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12734225#action_12734225 ]
Philip Zeyliger commented on THRIFT-546:
----------------------------------------
+1 on the idea.
There are a couple of alternate approaches here:
1) As you mention, static methods (as_dict, to_string, from_string) might be nicer. (Java has values() and valueOf() on the class, and ordinal() and toString() on a method.)
2) If you define __int__, I think the type coercion will work reasonable in many cases. Still won't be backwards compatible, though.
3) You could write a helper class TEnumeration, which has the relevant methods. It could call into Operation._values, for example.
-- Philip
> Python generated code should give the ability to convert to/from string names of enums
> --------------------------------------------------------------------------------------
>
> Key: THRIFT-546
> URL: https://issues.apache.org/jira/browse/THRIFT-546
> Project: Thrift
> Issue Type: New Feature
> Components: Compiler (Python)
> Reporter: Todd Lipcon
> Assignee: Todd Lipcon
> Attachments: thrift-546.txt
>
>
> The current code just generates enums as int constants namespaced within a class. This patch adds dictionaries in that class called TO_STRING and FROM_STRING, so enum values can be nicely printed in log messages, etc.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.