Hi, jython-users!

Can you help me and say what I do wrong?

 

I’m trying to convert *.py to java-classes:

I have 1 module – foo.py:

 

x = 2

x = int(raw_input("Please enter an integer: "))

print x

 

from Fibo import *

fibo.fib(1000)

 

where fibo.py is:

 

# Fibonacci numbers module

__all__ = ["fib","fib2"]

 

def fib(n):    # write Fibonacci series up to n

    a, b = 0, 1

    while b < n:

        print b,

        a, b = b, a+b

 

def fib2(n): # return Fibonacci series up to n

    result = []

    a, b = 0, 1

    while b < n:

        result.append(b)

        a, b = b, a+b

    return result

 

I’m using jythonc.bat to convert *.py files to java one:

At first:             C:\jython-2.1>jythonc Fibo.fibo

At second:        C:\jython-2.1>jythonc foo

 

Then I’m trying:

C:\jython-2.1\jpywork>java -classpath .;c:\jython-2.1\jython.jar foo

 

And obtain such stacktrace:

4

Please enter an integer: 21

21

Exception in thread "main" Traceback (innermost last):

  File "C:\jython-2.1\foo.py", line 0, in main

AttributeError: class 'Fibo.fibo' has no attribute 'fib'

 

But when I’m trying to execute foo.py in jython itself? All works fine !

 

C:\jython-2.1>jython

Jython 2.1 on java1.4.2 (JIT: null)

Type "copyright", "credits" or "license" for more information.

>>> import foo

4

Please enter an integer: 2

2

1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 >>>

 

What I’m doing wrong???