Help me on function definition

Ben Finney bignose+hates-spam at benfinney.id.au
Fri Mar 28 22:16:07 EDT 2008


"aeneng" <aeneng at yahoo.com> writes:

> I am just starting to use python in numerical cacluation. 

Welcome, and congratulations on learning Python.

> I need you to help me to see what's wrong with the following piece
> of codes [...]

Your code is rather difficult to read, since your expressions have all
the characters mashed together without spaces. It will help others who
read your code if you follow the Python coding guidelines in PEP 8
<URL:http://www.python.org/dev/peps/pep-0008>.

You should also choose names that are descriptive when someone reads
the code, and not single-character algebraic names.

> when I import the function, error message show like this
> >>> import cross
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "cross.py", line 8
>     ppp2=u[2]*v[0]-u[0]*v[2]
>     ^
> SyntaxError: invalid syntax
> 
> WHAT IS WRONG WITH MY CODE?

I suspect you will gain enlightenment in this case by running your
code via 'python -t foo.py' where 'foo.py' is the Python module you're
trying to run. (You can see a description of that option with 'python
-h' to display the commandline help.)

-- 
 \        "I have one rule to live by: Don't make it worse."  -- Hazel |
  `\                                                          Woodcock |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list