Showing posts with label python 3. Show all posts
Showing posts with label python 3. Show all posts

Sunday, March 28, 2010

Python 3, Part 6 (Functions)



In this tutorial, we are going to see how to write and call functions in Python 3, as well as how to pass arguments, both as keyword and value, to a Python function. I will also introduce you to some of the neat features of the Blender 2.5 text editor, such as source code color coding, which help make coding Python scripts much easier. This video is based on the Python 3.1 function tutorial at: http://docs.python.org/release/3.0.1/tutorial/controlflow.html#more-on-defining-functions.

Wednesday, March 10, 2010

Python 3, Part 5 (List Methods)



In Part 4, we saw how to use slicing to work with parts of a string, list, or tuple, as well as how to insert, delete, and add to these types of variables. Python has a number of built in methods -- also called functions -- that can do these operations in a way that makes the code easier to read. Sometimes it's a bit hard to understand all those colons and square brackets, and it's easier to use words like append, remove, or insert, which are, indeed the names of methods associated with lists. We'll also see how these easy to understand methods can be used to build a simple stack (where the last element added is the first element retrieved) or queue (where the first element added is the first element retrieved). We'll also discover how to sort, count, and locate items in a list. Along the way, we'll learn about the autocomplete feature of Blender's Python console, a handy feature that documents available methods.

Python 3, Part 4 (Slicing)



In Part 3, we were introduced to lists, which lets us work with more than one variable at once. We also saw how to reference parts of the list, say the 3rd element in the list x as x[2] (since we start numbering from 0), using the [] operator, and how to use negative numbers to reference list elements from the end. In this tutorial, we will go into more detail about how to get parts of strings and lists, by use of slicing. Slicing also uses the square brackets, but in a new and different way.

Monday, March 8, 2010

Python 3, Part 3 (Lists)



In Part 2, we saw different ways that string variables can be defined. In this tutorial, we will see how lists of variables can be defined and used. You're basically creating more than one variable at a time, in a structure called a list. Lists are a very important part of Python. If you want to be able both program in Python and to read Python code written by others, you need to know how lists work. Don't worry, you'll get the hang of it if you practice a bit.

Python 3, Part 2 (Strings)



In Part 1 of this series, we saw how to use Blender's Python 3 console, as well as how to write simple one line programs and make variable assignments. In this tutorial we are going to dig deeper in strings, arguably the most important type of variable in Python. We'll discover how to write strings, what happens when strings become very long or span more than one line, and how to use operators to combine strings or to make multiple copies of the same string text.

Saturday, March 6, 2010

Python 3, Part 1 (Expressions)



The goal of this tutorial is to introduce Blender users, whether or not they are programmers, to Python 3. Blender 2.5 supports Python 3 scripts, which can let you program Blender behavioer very precisely. Of course, before you can create Blender scripts, you need to know Python 3. We will use the Blender 2.5 Scripting environment, which includes a Python console that supports most (but not all) of Python 3, as well as a fully featured text editor, with advanced features such as autocomplete and automatic indenting of code. I will point out where Blender's Python implementation differs from the standard Python 3 distribution. There are minor differences, none that should prevent you from writing fully featured scripts in Blender 2.5.