# - Pound sign
# This is a comment ob = bpy.data.objects["Panel"]
List
a = [1,4,5,6,9,10] print (a[0]) 1 print (a[1:2]) 4, 5
a = 'hellothere' print (a[4:]) 'othere'
Dictionary (like a hash map)
a = {} a['name'] = 'bob' a['age'] = 44 print (a) {'age': 44, 'name': 'bob'}
def myfunction(aNumber=1, aString="hello"): result = '' for i in range(aNumber): result += aString return result
Indents matter, usually 4 spaces.
for i in range(2,10): print (i)
or use xrange(2,20) for lazy, as-needed streaming of content.
if a ==10: print 'yes' else: print 'no'
class Boy() def setName(self, n): self.name = n def getName(self): return self.name
self is like *this* in Java. If you don't provide “self,” you are referring to the global variable.
b = Boy() b.setName("bob")
(Don't forget the parentheses.)
print ("Hello, world!")