Also just some general stuff since I’m at work and don’t feel like actually working:
the ls command has a number of type-specific flags. Cameras is one of them. And beyond that you can specify a list of types using the type flag.
# Returns any selected camera shapes (not the camera transform!)
cmds.ls(sl=True, cameras=True)
# Does the same thing
cmds.ls(sl=True, type='camera')
# Type can also be a list which means you can return more than one type of selected item at once
cmds.ls(sl=True, type=['camera', 'nurbsCurve'])
You don’t need to use parentheses to combine strings. In fact you should use python’s string formatting instead of the + operator.
anysettingyouwant = '{0}.verticalFilmAperature'.format(cameraShape)
Don’t use list as an attribute name. It’s a built-in and you don’t want to override them as a general rule
print list
<type 'list'>
None, an empty string, and an empty list: they all have a boolean value of False and when doing True/False tests in python you can just use if/if not:
if object:
# True
if not object:
# False
So in your case (using your attribute name list):
if list:
for eachattribute in list:
...