<div dir="ltr">thanks!</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Chris Williams<div>Senior Web Developer</div><div>Clearwater, FL</div><div>731-445-4904</div></div></div></div>
<br><div class="gmail_quote">On Mon, Feb 12, 2018 at 5:21 AM, Duncan Grisby <span dir="ltr"><<a href="mailto:duncan@grisby.org" target="_blank">duncan@grisby.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, 2018-01-30 at 16:30 -0500, chris williams via omniORB-list<br>
wrote:<br>
<span class=""><br>
> Is it possible to convert a string to omniORB.EnumItem instance ? I<br>
> want to be able to accept a command line parameter and convert that<br>
> to enum.<br>
><br>
> I have an enum defined as such in IDL:<br>
><br>
> enum IdlCommandType<br>
> {<br>
> IDL_SETTINGS,<br>
> IDL_STATS<br>
><br>
> }<br>
><br>
> If I accept a command line parameter "IDL_SETTINGS" (as a string),<br>
> what is the python code to convert this to<br>
> type _GlobalIDL.IDL_SETTINGS ?<br>
<br>
</span>That's just standard simple Python:<br>
<br>
param = # the parameter from the command line<br>
item = getattr(_GlobalIDL, param)<br>
<br>
<br>
If you want to check that the value really does belong to the right<br>
enum, you can see if it is in the items:<br>
<br>
if item in _GlobalIDL.IdlCommandType._<wbr>items:<br>
# It was a valid enum item<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
Duncan.<br>
<br>
--<br>
-- Duncan Grisby --<br>
-- <a href="mailto:duncan@grisby.org">duncan@grisby.org</a> --<br>
-- <a href="http://www.grisby.org" rel="noreferrer" target="_blank">http://www.grisby.org</a> --<br>
<br>
</font></span></blockquote></div><br></div>