User Tools

Site Tools


Sidebar

Dan's Wiki

DokuWiki Instructions (local) DokuWiki Manual
Site Checker (Orphans Wanted)

Edit Sidebar

programming:python:start

This is an old revision of the document!


Python Cheat Sheet

Comments

# - Pound sign

# This is a comment
ob = bpy.data.objects["Panel"]

Data types

List

a = [1,4,5,6,9,10]
print (a[0])
    1
print (a[1:2])
    4, 5

Functions

def myfunction(aNumber=1, aString="hello"):
    result = ''
    for i in range(aNumber):
       result += aString
    return result

Syntax

Indents matter, usually 4 spaces.

Loops

for i in range(2,10):
    print (i)

or use xrange(2,20) for lazy, as-needed streaming of content.

Conditional

if a ==10:
   print 'yes'
else:
   print 'no'
programming/python/start.1544058655.txt.gz · Last modified: 2018/12/06 01:10 by dwheele