exec() for node output



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/12/2011 at 07:28, xxxxxxxx wrote:

    Hey people,

    here's another expression node port related question:
    I am making a simple script to help someone out, but running in to this: the node has a bunch of output ports, Port1, Port2, Port3 etc, and I use the exec() statement to calculate a value for the variables Port1 etc. I use a counter to name the Ports and assign the value of an array to it in a for loop, so i am not directly assigning a value with 'Port1=whatever".

    Like so:
    Outcode="Port"+str(counter+1)+" = TheArray[counter]"
    exec(Outcode)

    If I check the value for Port1, it is fine, but I get an error:
    NameError: Could not find port value for 'Port1' in node 'Python'.

    The whole idea is not to have to assign values to ports in the code, but to have the code still work when the user adds more ports manually following the same naming convention.

    Any ideas?

    Regards,
    Dr. Scarlett



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/12/2011 at 07:37, xxxxxxxx wrote:

    That was weird. The minute I posted this, I received answer elsewhere.

    Thanks, Nux!

    Here's the link.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/12/2011 at 08:39, xxxxxxxx wrote:

    And this is what it was about


Log in to reply