Running Python from UNIX

Martin v. Loewis martin at v.loewis.de
Tue Aug 6 11:15:51 CEST 2002


anandrs at hexaware.com (Anand Ramakrishna) writes:

>    I am a total newbie to Python. I am just learning it in Solaris
> environment. I wrote a small function to compute fibonacci series. If
> I type and run it in the regular line interpreter mode, it runs giving
> me the correct result. If I write this as a script and execute the
> script, it runs without errors but does not print the result. 

Yes, that's a feature of the interactive intepreter only: If it
evaluates an expression, it prints the result. In a script, evaluation
of an expression does not cause the result to be printed.

In a script, you need the print statement:

print fib(6)

HTH,
Martin



More information about the Python-list mailing list