python - Using a list in multiple Functions -


Is it possible to use a function in a function created in a separate function?

I created a list of disks in this function:

  def create_discs (): disc_list = ['disc0', 'disc1', 'disk2']  

I would like to use this list in a separate function

  def move_discs cmds.move (disc_list [1], 0, 0, 5)  

I get this error when I try to:

  name error: file & lt; Maya Console & gt; Line 48: The global name 'disk_list' is not defined #  

I am using Autodesk Maya

If you do not want to use classes to keep the state, you may have a global variable or you can create_list ()

  disk_list = [] def create_list (): global disc_list disk_list = ['disc0', 'Disk 1', 'disk2'] def move_discs cmds.move (disc_list [1], 0, 0, 5)  

Note that The use of global variables is not encouraged.

Returning list create_list () from:

  def create_list (): ['disc0', 'disc1 ',' Disks 2 '] DEF LEV_DISK (): Disk_list = Make_list () cmds.move (disk_list [1], 0, 0, 5)  

But I do not think it's too much As you help you need to keep the status of your list in the program.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -