Erel B4X founder Staff member Licensed User Longtime User Oct 10, 2017 #3 Use smart strings: Code: Py.Execute($" print 'hello world' def fib(n): if n == 1 or n==2: ... "$)
wonder Expert Licensed User Longtime User Oct 10, 2017 #4 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: Oct 10, 2017
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?
Erel B4X founder Staff member Licensed User Longtime User Oct 10, 2017 #5 wonder said: This works, but it breaks the B4A code's indentation. Click to expand... B4A will not do anything with multiline strings. Just make sure not include any extra tabs in your code.
wonder said: This works, but it breaks the B4A code's indentation. Click to expand... B4A will not do anything with multiline strings. Just make sure not include any extra tabs in your code.
thedesolatesoul Expert Licensed User Longtime User Oct 11, 2017 #7 Very nice. Does it handle imports and have standard libraries? There is an insane amount of python code out there, i wonder if its possible to setup a flask or django webserver with this.
Very nice. Does it handle imports and have standard libraries? There is an insane amount of python code out there, i wonder if its possible to setup a flask or django webserver with this.
thedesolatesoul Expert Licensed User Longtime User Oct 11, 2017 #8 Well Import sys Sys.exit(0) Worked! Couldnt import anything else.
OliverA Expert Licensed User Longtime User Oct 11, 2017 #9 thedesolatesoul said: i wonder if its possible to setup a flask or django webserver with this. Click to expand... Like this? (https://blog.kivy.org/2016/05/android-apps-with-python-flask-and-a-webview/).
thedesolatesoul said: i wonder if its possible to setup a flask or django webserver with this. Click to expand... Like this? (https://blog.kivy.org/2016/05/android-apps-with-python-flask-and-a-webview/).
thedesolatesoul Expert Licensed User Longtime User Oct 11, 2017 #10 I guess so. Although i didnt think this through, it might sound like a html app but there is python behind it. Python has great libraries for all the backend stuff like connecting to dbs, network, scraping.
I guess so. Although i didnt think this through, it might sound like a html app but there is python behind it. Python has great libraries for all the backend stuff like connecting to dbs, network, scraping.
wonder Expert Licensed User Longtime User Oct 11, 2017 #11 I haven't had the time to experiment yet. I'll be writing the rest of the library during the weekend. Regarding imports, TensorFlow would be cool...
I haven't had the time to experiment yet. I'll be writing the rest of the library during the weekend. Regarding imports, TensorFlow would be cool...
thedesolatesoul Expert Licensed User Longtime User Oct 11, 2017 #12 Tensorflow was indeed what I was thinking Its a really cool idea, it lets you write and test the application logic separate from the ui. Nice job once again.
Tensorflow was indeed what I was thinking Its a really cool idea, it lets you write and test the application logic separate from the ui. Nice job once again.
wonder Expert Licensed User Longtime User Oct 11, 2017 #13 Thanks!!! I think I'll start with some simple libraries like 're' or 'numpy'. I'll have to dive into the CPython documentation: https://docs.python.org/2/c-api/import.html
Thanks!!! I think I'll start with some simple libraries like 're' or 'numpy'. I'll have to dive into the CPython documentation: https://docs.python.org/2/c-api/import.html
wonder Expert Licensed User Longtime User Oct 14, 2017 #14 thedesolatesoul said: Does it handle imports and have standard libraries? Click to expand... It seems that, if we copy the modules we need into File.DirDefaultExternal, we'll be able to import them! This code will be automated, so that all you need to write is: Code: import some_cool_module
thedesolatesoul said: Does it handle imports and have standard libraries? Click to expand... It seems that, if we copy the modules we need into File.DirDefaultExternal, we'll be able to import them! This code will be automated, so that all you need to write is: Code: import some_cool_module
walterf25 Expert Licensed User Longtime User Oct 20, 2017 #15 wonder said: It's alive!!!! View attachment 60408 Click to expand... Wow, i have been doing some Python coding myself lately, it's so nice to see this here, just more goodies for us, Yay!!!
wonder said: It's alive!!!! View attachment 60408 Click to expand... Wow, i have been doing some Python coding myself lately, it's so nice to see this here, just more goodies for us, Yay!!!
wonder Expert Licensed User Longtime User Oct 29, 2017 #16 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: Oct 30, 2017
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.