Hi Sam,

When you refer to modules, it sounds like you mean functions. A function is
this:

def aFunc(arg, arg2, arg3):
    return arg + arg2 + arg3

​

A module is a file (usually) that can be imported into another, and can
provide a namespace for its contents:

# aModule.pydef aFunc(arg, arg2, arg3):
    return arg + arg2 + arg3# main.pyimport aModule
aFunc(1,2,3)

​

You will need to provide a more complete example for us to get a better
idea about your question.
But yes it is a pretty common workflow for a function to accept parameters
and return results. However, if you are talking about configuration
variables, it can also be common to have a config class or module (a real
module), which gets set up once and can be accessed globally in other parts
of your code. Something like this could be one approach:

# conf.pyclass Config(object):

    def __init__():
        self.number = 1
        self.name = "Name"

DefaultConfig = Config()
# main.pyimport conf
def main(config):
    pass
def doWithDefaults():
    number = conf.DefaultConfig.number
    name = conf.DefaultConfig.name
    # ...
if __name__ == "__main__":
    # ... parse command args ...
    config = conf.Config()
    config.number = parsedNumber
    config.name = parsedName

    main(config)

​
Is this what you are after?

Justin


On Sat, Jun 18, 2016 at 6:48 AM <[email protected]> wrote:

> Hello,
>
> i have a script which i think is split up appropriately into modules.
> However my main run() module takes variables set in a config() module and
> calls the other modules, using the configured variables as arguments.
>
> but it is becoming a bit tedious when i need to return back each time with
> the modified variables, or extra variables, which need to be transferred
> back to the run() module and then out again to the next module.
>
> eg
>
>
> createCurves.execute(circle_counter,limb_counter,configured.curves,curr_circ_center,limb_vec,crv_pnt1,crv_pnt2)
>
> is this normal? or is there a cleaner way to communicate the current
> variable states between modules.
>
>
> thanks,
> Sam
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/ee3e0a6f-f3dc-4cbe-a99d-4b69fa7cd722%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3gFZoPYeGTNGS7j2YsNajcBbb7Mav76JXPjUN0F73uUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to