When I print the object I get: {'ip': 'ip', 'ip1': 'hi'}
But if I try to print the length of that I get:
Traceback (most recent call last):
print len(options)
AttributeError: Values instance has no attribute '__len__'
I just need to know how many items are in that object (which appears to just be a dictionary).
Here is the whole code:
#!/usr/bin/python
from inspect import getmembers
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-a', '--allow',
action="store", dest="ip",
help="query string", default="spam")
parser.add_option('-d', '--deny',
action="store", dest="ip1",
help="query string", default="spam")
options, args = parser.parse_args()
print 'Query string:', options.ip
print 'Query string:', options.ip1
count=0
for i in options:
count+=1
print count
if 1:
print "Max number of options 1"
exit