I am a Python beginner

I am a complete noob with python. i would like to find a tutorial that starts at the beginning and works its way up. I have a basic understanding of python (i know what some of it does) but i would like to learn more.

when i say “the beginning” i mean the very beginning, like printing a line out in the console that says “hello world”

thank you for your help

hmm, where to begin. Let’s start with this…bookmark these pages

http://www.blender.org/documentation/blender_python_api_2_63_7/contents.html
http://docs.python.org/py3k/reference/index.html

then read through some of the template scripts that come with blender. They will be over your head at first, but just start reading them. People learn languages fastest when they are immersed. I’m sure other people can chime in as well.

Don’t start with trying to do Python inside of Blender. Just worry about learning plain Python then come back to Blender once you understand the basics. You probably don’t want to start with looking at the templates in Blender because then you will be trying to learn Python at the same time you are trying to learn the Blender API.

I read though this to get up to speed on Python (http://docs.python.org/tutorial/). This tutorial looked a little more entry-level as well: http://www.sthurlow.com/python/. Lastly, this looks promising as well because it has some sample programs that will give you some simple problems to code up http://code.google.com/edu/languages/google-python-class/

In no particular order:

Download the zips of the python documentation and the blender documentation, put them in your reference or documents folder, and bookmark them so that looking something up is as fast as possible.

Of the python reference, the “language reference” is obviously important, but of the library reference, you couldn’t spend enough time learning the builtin functions and special method names.

One nice thing about blender’s console (shift-F4) is it’s autocomplete. (cmd+space on mac but I forget what the hotkey is for windows…) In the absence of autocomplete, you can always do a print(dir(the_something)) to learn more about ‘the_something’

Setting up an IDE like eclipse or vim is a subject unto itself and not something I would necessarily jump straight into when just beginning, but whatever editor you decide to use, make sure that it is set up to turn tabs into four spaces. One tab stuck in with all the rest spaces makes for a very confusing bug. Beware of copy-pasting in code from the nets and getting tabs mixed in with your spaces. Sometimes its best just to TYPE all of it in instead of pasting, just to be sure that all your indentation consists solely of spaces, not tabs.

You didn’t mention OS… may we assume that windows is what you are using? Regardless of platform, It is a common question to ask, “How do I see blender’s debugging output?”
— The windows version of blender >> Help Menu >> ( show the console )
— Mac or linux – if you want that terminal you have to actually start blender from one.

IDLE is NOT GREAT but it is specifically made for learners like yourself. “Playing around” in the python shell is probably the single most educational activity you can do at this point. IDLE comes along with a system install of python ( system python is distinct from blender’s built-in python) So you have at least three options for getting to a python shell:

windows: (WIN+R) >> cmd.exe >> python
mac: (cmd+space) >> terminal.app >> python

using IDLE
or

using Blender’s python console (shift+f4 with mouse over a region makes that region a console)

One last bit of possibly very bad advice: At some point you will probably want to try making an Addon. You will want a smooth debugging workflow, right? Before you jump straight to ‘Addon’, which must be enabled in the preferences, must contain a bl_info, must register properly, etc… Here’s what I suggest:

Find your <userscripts>/startup folder. You may have to create it. The location depends on which OS. Any scripts you have in there will run when you start blender.
You still have to follow the idiom of if name == ‘main’ … but you don’t need to fill out the bl_info or check the box in the preferences to enable your addon. tl;dr; the startup folder is a good place for your scripts to incubate, before you graduate them to full-fledged addons.

I am somewhat familiar with the Blender API, but only know BASIC from the apple II days. Why would a book introducing and teaching how to use Python 3 to program Blender 2.69 -2.70 Be so difficult and/or tedious ? Just to learn mostly how to generate primitives and/or to manipulate and modify them and their several parts in an add-on format would be killer. As of now, there is nothing like this. I would buy it. Programing is the industry of the future, and Blender is the 3D engine of the future. I will take this advice;

{ http://www.blender.org/documentation.../contents.html
http://docs.python.org/py3k/reference/index.html
http://www.google.com
then read through some of the template scripts that come with blender. They will be over your head at first, but just start reading them. People learn languages fastest when they are immersed. I’m sure other people can chime in as well.}

and I already am, but I still yearn for educational text. Like reference for the rest of us.

Hey check this YouTube playlist.
Very easy to follow short informative Clips.
Even covers installation and setup with Python 3+.

Hey Boomer, where’s the link? :slight_smile:

Some people may advocate learning python outside of Blender, and that is good advise for people who are not to visual or who are great at reading technical data without getting bored out of their skull. I am not that way. I had programming experience before learning Python too though. I have learned enough to build a random level generator, and rig a skeleton using Python, along with some good tricks for finding what I need in Python. My advise would be, if you are a visual person, check out some of the python tutorials on youtube, spend time here in this forum, and read code that others have written, it will help you a lot. I have a tutorial on my LinkedIn group site which tackles one of the most frustrating things for newcomers to Blender - context issues - actually I will paste it here:

One of the most common problems that you will run into, is the command prompt will give you an error saying you are “out of context” . . . so your question becomes, "Well, what is IN context? A trick I use to find out is this:

Let’s say you have the code:
original_type = bpy.context.area.type
bpy.context.area.type = “VIEW_3D”
bpy.ops.object.origin_set(type=‘GEOMETRY_ORIGIN’)
bpy.context.area.type = original_type

Which helps you switch context. But that is not what you want . . . you want a list of what contexts are available, so you can find out why you are getting the out of context error . . . . what I do, is just change the second line so that it will error out, and voila, you get your list of contexts:

bpy.context.area.type = “VIE”
Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
TypeError: bpy_struct: item.attr = val: enum “VIE” not found in (‘VIEW_3D’, ‘TIMELINE’, ‘GRAPH_EDITOR’, ‘DOPESHEET_EDITOR’, ‘NLA_EDITOR’, ‘IMAGE_EDITOR’, ‘SEQUENCE_EDITOR’, ‘CLIP_EDITOR’, ‘TEXT_EDITOR’, ‘NODE_EDITOR’, ‘LOGIC_EDITOR’, ‘PROPERTIES’, ‘OUTLINER’, 'USER)

I checked to see if it was available using the help or dir commands . . . . but could not find a thing. That said, the help and dir commands are very useful. You can use these commands to get more information . . .

help(bpy.context.area.type)

or

dir(bpy.context.area.type)

Another thing that is extremely helpful, especially when you do not know what options you have, is use the autocomplete button at the bottom of the console . . . put in the path you are working with, and leave a “.” at the end, then press the autocomplete button . . .

bpy. then press the autocomplete button . . . and it gives . . .
app
context
data
ops
path
props
types
utils

Last but not least, you can get a lot of information from the API, just make sure you are looking at an up-to-date API, as older API’s are nearly worthless.

There are other tutorials on my LinkedIn group, (Blender Open Artist Group) here http://www.linkedin.com/groups?home=&gid=6677523, this is an open group, so anyone can join it. I have open source code there, with a link for a tutorial for building a random level generator in Blender using Python, and some auto-rigging code in Python. There are other non-Python Blender tutorials as well, anyone can post tutorials there.