How to share global variables between python files

Forum Forums Visual Components 4.0 Python Programming in VC How to share global variables between python files

Be sure to read the Forum Rules and Guidelines before start using the Forum.

This topic contains 3 replies, has 4 voices, and was last updated by Johnny Johnny 1 week, 2 days ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #10736

    shushu
    Participant

    I have one task list (tasks = [task1,task2,task3]) to be executed using AGV caller, however new task will be assigned using tasks.append(new task) as well when running the current task list. How can two scripts using the same global variable. I tested the import X.py module like below doesn’t work.

    ===============================================

    File: config.py

    x =0 # Default value of the ‘x’ configuration setting
    File: mod.py

    import config
    config.x = 1
    File: main.py

    import config
    import mod
    print config.x

    ==============================================

    #10754
    zesty
    zesty
    Moderator

    My only advice would be use a component property or add a property to an object like a behavior that can be accessed by getting the object.

    #10774

    Ralle
    Participant

    This is a feature that is really missing and it is on my personal feature wish list since several years. At the moment it is only possible to share values of component properties or to send signals between the scripts as zesty already mentioned.

    The only way that succeed for me without using that sharing is to use the ctypes module and working with ctypes pointers from integer addresses. But for a clear working you need a lot of overhead to organize the python objects.

    #11452
    Johnny
    Johnny
    Participant

    I agree something like that would be awesome!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.