Showing category "Python" (Show all posts)

Understanding 'with' in Python

Posted by Jeremy YeoKhoo on Sunday, November 30, 2014, In : Python 
I've found a link to giving a very detailed and simple to understand explanation using the statement 'with' in python, and to summarise...Well if we use 'with', python will close the function that is called within the body of with. Say for an example using the in built function of open in Python, usually you will need to close that function. With 'with', Python does that for you. Simple.
with open("x.txt") as f:
  data =
  do something with data

Continue reading ...

Create joints between startJoint and endJoint

Posted by Jeremy YeoKhoo on Friday, May 23, 2014, In : Python 
Hey guys, here is another simple script that I have found invaluable. Basically whilst rigging, I find that numerous times I need to create 'midJoints' between a startJoint and an endJoint. 

Here it is, feel free to use it around where you see fit in your everyday toolsets.

import maya.cmds as cmds
import maya.OpenMaya as OpenMaya

def createMidJoints(startJoint, endJoint, steps= 2):
  sPos= cmds.xform(startJoint, q=1, ws=1, t=1)
  ePos= cmds.xform(endJoint, q=1, ws=1, t=1)

  vecA= OpenMaya...

Continue reading ...

PEP8: Style Guide for Python

Posted by Jeremy YeoKhoo on Saturday, May 10, 2014, In : Python 
I thought I might mention PEP8 which is basically a style guide for writing your code in Python. Here\s the link:
PEP 8 -- Style Guide for Python Cod

Continue reading ...

About Me

Character TD and Creature TD with some generalist skills