Y que tal esto:
#!/usr/bin/env python
#-*- coding: utf-8 -*-
from optparse import OptionParser
class ClaseGlobal(object):
a = 0
def test_func():
print ClaseGlobal.a + 2
def main():
parser = OptionParser()
parser.add_option('-t','--run_test', action='store_true', dest='run', \
help='Run test',default=False)
parser.add_option('-n', '--number', help='Number', dest='number', \
action='store', type='int', default=None)
options, args = parser.parse_args()
if not options.number:
ClaseGlobal.a = 1
else:
ClaseGlobal.a = options.number
if options.run:
#global a
test_func()
if __name__ == '__main__':
main()
_______________________________________________
Python-es mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/