Python in B4A is now a reality!

wonder

Expert
Licensed User
Longtime User
It's alive!!!! :D

upload_2017-10-8_14-35-39.png
 
Last edited:
I tried, but the interpreter kept complaining about the indentation. I'll give it another go.

Edit: This works, but it breaks the B4A code's indentation.
Code:
'Example:
    Py.Execute($"
print 'hello world!'

def fib(n):
    if n == 1 or n == 2:      
        return 1
    return fib(n - 1) + fib(n - 2)

print fib(16)"$ _
    )

Anyway, this is just an example. Code can be entered from a text box as well.
I'll probably be able to post an example app this evening.

B4A plays well with C/C++, Java, PHP, SQL and now, even Python! Isn't it wonderful? :)
 
Last edited:
Does it handle imports and have standard libraries?
It seems that, if we copy the modules we need into File.DirDefaultExternal, we'll be able to import them! :)

upload_2017-10-14_21-37-53.png


This code will be automated, so that all you need to write is:
Code:
import some_cool_module
 
For the ones interested, NinjaPython has officially been released! :)

Please give my library a test-drive:
https://www.b4x.com/android/forum/threads/ninjapython-cpython-interpreter.85220/#post-539824

Using it is as simple as:
Code:
Py.Initialize
Py.Exec(pythonCode)
Py.Finalize

If possible, please let me know if the test project works without problems and your device architecture (x86, ARM, ARMv7, ARMv8_64 or x86_64). Emulator results are also welcome.

I'm still figuring out a few things, namely 3rd party library support, but the current version is interesting and functional enough to do some really cool things.
 
Last edited:
Back
Top