Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python scripts: handling PF_OPTION and PF_RADIO choices by name
#5
(08-15-2018, 11:17 PM)Ofnuts Wrote:
Code:
def createButtons(name,pairs):
    optsclass=namedtuple(name+'Type',[symbol for symbol,label in pairs]+['labels'])
    opts=optsclass(*(range(len(pairs))+[[(label,i) for i,(symbol,label) in enumerate(pairs)]]))
    return opts

You've been super helpful, and I thank you a lot.  I have a new respect for the power and flexibility of python, too.

I only have one more question. What would I look up to gain a better understanding of how the for/in syntax works in this code?  I'm quite curious about it, but I don't even know what terminology it would fall under.
Reply


Messages In This Thread
RE: Python scripts: handling PF_OPTION choices by name - by lordcayleth - 08-16-2018, 07:22 PM

Forum Jump: