Instantiating for loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cole
    New Member
    • Dec 2007
    • 4

    Instantiating for loop

    Is there a way to do this with some kind of a loop? thanks!

    Code:
        if refrence == "Loshlf_16": b=Loshlf_16.execute()
        elif refrence == "Loshlf_20": b=Loshlf_20.execute()
        elif refrence == "Loshlf_25": b=Loshlf_25.execute()
        elif refrence == "Loshlf_32": b=Loshlf_32.execute()
        elif refrence == "Loshlf_40": b=Loshlf_40.execute()
        elif refrence == "Loshlf_50": b=Loshlf_50.execute()
        elif refrence == "Loshlf_63": b=Loshlf_63.execute()
        elif refrence == "Loshlf_80": b=Loshlf_80.execute()
        elif refrence == "Loshlf_100": b=Loshlf_100.execute()
        elif refrence == "Loshlf_125": b=Loshlf_125.execute()
        elif refrence == "Loshlf_160": b=Loshlf_160.execute()
        elif refrence == "Loshlf_200": b=Loshlf_200.execute()
        elif refrence == "Loshlf_250": b=Loshlf_250.execute()
        elif refrence == "Loshlf_315": b=Loshlf_315.execute() 
        elif refrence == "Loshlf_400": b=Loshlf_400.execute()
        elif refrence == "Loshlf_500": b=Loshlf_500.execute()
        elif refrence == "Loshlf_630": b=Loshlf_630.execute()
        elif refrence == "Loshlf_800": b=Loshlf_800.execute()
        elif refrence == "Loshlf_1000": b=Loshlf_1250.execute()
        elif refrence == "Loshlf_1600": b=Loshlf_1600.execute()
        elif refrence == "Loshlf_2000": b=Loshlf_2000.execute()
        elif refrence == "Loshlf_2500": b=Loshlf_2500.execute()
        elif refrence == "Loshlf_3150": b=Loshlf_3150.execute()
        elif refrence == "Loshlf_4000": b=Loshlf_4000.execute()
        elif refrence == "Loshlf_5000": b=Loshlf_5000.execute()
        elif refrence == "Loshlf_6300": b=Loshlf_6300.execute()
        elif refrence == "Loshlf_8000": b=Loshlf_8000.execute()
        elif refrence == "Loshlf_10000": b=Loshlf_8000.execute()
        elif refrence == "Loshlf_12500": b=Loshlf_12500.execute()
        elif refrence == "Loshlf_16000": b=Loshlf_16000.execute()
        elif refrence == "Loshlf_20000": b=Loshlf_20000.execute()
  • boxfish
    Recognized Expert Contributor
    • Mar 2008
    • 469

    #2
    I think so, but not a loop. You could do this with the exec keyword:
    Code:
    exec "b=" + refrence + ".execute()"
    Hope this helps.

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #3
      You can also use eval:[code=Python]b = eval("%s.execut e()" % refrence)[/code]

      Comment

      Working...