SimplyMaya
Community
The SimplyMaya Forums
View all Forums
A place you can ask or answer VFX related questions
Latest forum posts
Safari browser for Simply Maya?
Wireframe Playblaster for Maya - Render Your Wireframes With Ease!
Mr Bean Animation
Boolean>Difference - Problem
specular highlights at UV seam
Rig explodes when translation on splineIK on spine
News and articles
News & Articles
Vfx related news and articles
Random news
When Fine Art Goes Digital
Texture collaboration system (Coming Soon)
Upload or Download textures
A place to download great textures or share your own with the community
Legacy Resources
Latest uploads to our system
View new Posts
Edit your profile
View threads your subscribed to
User control panel
Training
Maya Training and Tutorials
View all training
View hundreds of hours of Maya training online or via download
Looking for something specific?
Focus on Archviz & Environments
Focus on Organics
Focus on Hard Surface
Focus on Lighting, Rendering & Texturing
Focus on Dynamics, Rigging & Animation
Post Production
Training options on SimplyMaya
Current member status:
Not logged in
Create Account
Pick a streaming payment plan
We offer several different subscription options for our online training
Try streaming for free
Watch up-to three hours of training over a 10 day period for free
Buy training for download
Choose the content you want and buy it outright, downloads don't expire and you can keep them for as long as you'd like
Latest training
Integrating 3D models with photography
Substance Painter 2017
Complex UV Layout in Maya 2018
Training you might like
Creating props for set dressing - Bonsai tree
Spach-Alspaugh House and Environment Volume 3
If you want to ask a SimplyMaya training related question use this forum:
SimplyMaya tutorials
Create Account
Sign in
Username
Password
Sign in
Forgot Password?
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?
Register
FAQ
Calendar
Mark Forums Read
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
yiingrou
View Public Profile
Find More Posts by yiingrou
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
Jackkd88
View Public Profile
Find More Posts by Jackkd88
Reply
«
Previous Thread
|
Next Thread
»
Thread Tools
Show Printable Version
Email this Page
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