SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.


SM Forums / Maya Questions / Programming / some python function is not working in maya?

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
 
Thread Tools
21-07-2020, 05:37 AM   #1
yiingrou
Registered User
 
Join Date: May 2020
Posts: 2
some python function is not working in maya?
hi, i am new to python ... recently i had watched some tutorial about python. and i try it, it work in IDLE but when i apply in MAYA it doesn't work... am i doing wrong?

the sample given in tutorial :
s = [1, 2, 3, 4, 5]
a, *b, c = s
>>a
1
..b
2, 3, 4
>>c
5


and here what i tried in maya2018:
import maya.cmds as cmds
selObj = cmds.ls(sl=1) #(i did select few item in maya)
a,*b = selObj
print (a)

and i get # Error: invalid syntax #

thanks in advance for spending time
  Reply with quote
03-09-2020, 10:02 AM   #2
Jackkd88
Registered User
 
Join Date: Sep 2020
Posts: 5
Asterisk (*) unpacking is introduced in python 3 , Maya still uses python 2 so this method won't work
Instead you can use this code:
import maya.cmds as cmds
selObj = cmds.ls(sl=1)
a,b = selObj[0],selObj[1:]
print a
print b
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Huge rendering time with maya fluids and arnold (2018) bybyle Dynamics & Special Effects 0 04-07-2019 05:44 AM
Maya Python: Building Generator Script Issues maxlaudenslager Programming 0 13-12-2018 09:12 PM
Little help with python FrancescoRon97 Programming 0 08-12-2018 10:57 AM
Maya 2015 Error loading scene Awad96 Maya Technical Issues 5 05-09-2015 03:24 PM
Maya Doesn't Startup Properly - Just Script Editor threedsnack Maya Technical Issues 1 04-02-2008 11:55 AM