Ok, im learning python so i tried to make my own script..

Guess what happend?
It dident WORK!
not to suprising…
well anyway, heres the script and its module (kewl! im talking about modules!!)

script:
import sys
sys.path
import function
a = function.GetNumber(3)
print a

on my desktop i have the script file: function.py:

def GetNumber(n)
a = n*2
return a

and i get this error:

a pointer at (n) and it says invailed syntax

Im not totaly sure about what its saying…
please help

When posting code, it helps to use the code tags on this forum. Indentation is very important in python, but if you don’t use the code tags it doesn’t show on the forum.

I spotted a small error: when you define a function you must end with ‘:’

def GetNumber(n):

oh yea, thanks XD

ok, iv changed that but now it says:

IdentationError: expected an idented block

But what iv read i dont have to define something like a
cuse if i say its a = n*2 then a is a variable and i dont have to ident a before saying what a is…
Right?

No, it’s inside a function. Every time you open a block (function, if, while, for, etc.) you need to indent what’s inside it.

These are basic Python issues. You’ll be able to find lots of resources on the internet about these basics that are not Panda-specific. This is not a Python-forum.

Ok now im confused @_@
Panda3ds programing lang is python
this is the help with script forum
so shouldnt this forum only contain posts as these?
Theres another forum for c++ in panda, this is the python forum…

This link will certainly help:
http://docs.python.org/tutorial/index.html

You should start at the begining, and not skip down to the later chapters. It takes between two hours and some days to go through the tutorials, depending on your skills.

Do NOT skip a lesson or example if it is not working!!! Ask questions on the Python forums UNTIL it is working!!! If you don’t manage to complete this tutorial you WON’T BE ABLE to do anything with Panda3D.

enn0x

but im already reading the “dive into python” manual
Is that one u mention one better?

Dive into Python is good if you have prior experience with programming concepts. Otherwise it is better to stick with beginner tutorials.

Both, the “official” Python tutorial and “Dive into Python”, are good tutorials. It’s a matter of personal taste. I personally prefer the offical tutorial.

No matter which one you choose, you have not read it carefully enough. The seconds chapter of “Dive into Python”, called “Your first Python program”, explains indention, and you obviously have problems with indenting (the first chapter is about installing)! So you can not have successfully passed the most basic chapter in “Dive into Python”!

Hmm… another thing. You might have noticed that you get some unfriendly responses. This had to be expected after your first posts. You came here and shouted (BIG LETTERS) that Panda3D/Python is not working. Not that you maybe don’t understand how to do it right or something, but that the tools you are working with are defect (I’m overdrawing a bit to make it clear). Now, most people here work successfull with Panda3D or even contribute to it, and telling them that their work is not working. What response do you expect? You are talking with real people here, who are not getting paid for being friendly (like support for a commercial product).

Look at it this way: you bought a new Harley Davidson. And now you want to customize it. But you don’t know how to use a scredriver or wench. And now you tell the local Harley club that their bikes are scrap. I would expect that they answer with their shotguns.

Maybe it would have been better to ask something like “Hello, I have a problem with basic programming, can you please give me a hint wat I made wrong”.

enn0x

Ofcurse i got angry since i did excacly what the manual told me to and still it dident work!
But what i dont get is why all of you becomes mean at me for like DAYS!
chill!!!
You guys are so freakn not forgiving!!!
On roblox forum u are allowed to get upset about something for one post, people doesnt care to remeber your mean comment!

GROW UP! People get upset sometimes, Get use to it!

Well, if you did everything the manual says, then you clearly missed the front page. It clearly says that Panda3D is a library for people who already are programmers, and thus you need to have proficient knowledge in Python or C++ first before you even start learning Panda3D.

We’re not getting angry at all. It’s you who’s angry, looking at the number of capitals and exclamation points in your posts.

i know i abuse ! and capitals, but thats not because im mad thats because if i use ! only it doesnt sound like im rasing my voice, and i do raise and lower my voice when i speak! may does…

  • i dont recall screaming: Panda3d DOESNT WORK!!!

and jepp!
I always skips intrucuctions XD
and the dive in is so much at same time so i dont remeber everything…

Only one question as i have ur attention: what does % do?
He never said what it did…
I get it like this:

“string %s” % value= takes the value and add it to the string

but he really is mixing alot with those % so what does one % do?

The problem is that we have to keep dealing with people who have not taken the important step of learning python before starting with Panda. The argumentative tones of your posts just made people more frustrated than usual, leading to more argumentative replies. You can’t expect to be able to post angry messages just because you are a new user without getting some of that frustration reflected back onto you by older users.

Granted, the manual didn’t seem to emphasize the importance of learning python before the working with panda quite enough but that has been rectified now. Please learn the basics of python, it’s quite easy and there are lots of free resources online for doing so but this forum is not for teaching basic python skills.

diveintopython.org/native_data_t … rings.html
docs.python.org/library/stdtypes … formatting

It would be more polite if you did not skip instructions before asking questions. Especially those questions that are already answered in the instructions.

Of course you are perfectly free to decide how much reading on your own time you want to do. But you should realize that when you make a post here, you are involving other peoples’ time as well as your own, and these other people may feel unhappy if it is evident that you didn’t do at least a minimum of your own research before asking them.

David

yea, im reading teh dive into panda im on chapter 5…
But i do miss alot therefore im about to read it again when im finished…
But still i ask questions about stuffs the manual doesnt cover/i missed…
But HEY!
i found out how to ident objects!!!
i re read the chapter 2 part about identin and found out that since python doesnt use ends u def the stuffs inside a function with 4 whitespace !!!
and i got my module to work!
Yea!!!

grats on your indentation problem.
but what you’r doing right now is “reading without understanding” which is pretty much useless if you want to learn programming.
start with chapter one. and once you understood everything in it, continue reading chapter 2. and so on. there is a reason why those things have a certain order. if you just jump around or skip parts you will have serious trouble understanding what they are doing.
just my 2 cents but i think those 2 cents are worth it^

yea, i dont skip parts, when im done with the chapter theres a list of things i should know before i move on…
I dont move on unless i know those things… More or less exact XD
Well, i just made my first working module script XD
Check this out:

The py file which u should run:

import sys
sys.path
import function

def Add():
    n = input("Type a Number: ")
    b = input(str(n)+" + ")
    a = function.GetNumber(n,b)
    print str(n)+" + " + str(b) + " is: "+ str(a)

def Double():
    n = input("Type a Number: ")
    b = input(str(n)+" * ")
    a = function.Double(n,b)
    print str(n)+" * " + str(b) + " is: "+ str(a)

def Devide():
    n = input("Type a Number: ")
    b = input(str(n)+" / ")
    a = function.Devide(n,b)
    print str(n)+" / "+ str(b) + " is: "+ str(a)

def Substract():
    n = input("Type a Number: ")
    b = input(str(n)+" - ")
    a = function.Substract(n,b)
    print str(n)+" - "+ str(b) + " is: "+ str(a)


n = input("List of math carculations: \n1: Add \n2:Substract \n3:Double \n4:Devide \nChose a number: ")
if n == 1:
    Add()
elif n == 3:
    Double()
elif n == 4:
    Devide()
elif n == 2:
    Substract()

else:
    print "You did not push any of the requested buttoms!"

And heres the function.py script which should be named function.py too:

def GetNumber(n,a):
    a = n+a
    return a

def Double(n,b):
    a = n*b
    return a

def Devide(n,b):
    a = n/b
    return a

def Substract(n,b):
    a = n-b
    return a

[/code]

sorry about that dicorder at the if n == …
But kewl Hu?!