Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
iPad2 keyboard
-
Can you guys recommend a iPad2 keyboard? Thanks
-
I use the normal Apple Wireless Keyboard, and so far I haven't had issues with the keyboard itself. External keyboard support in iOS is a bit unreliable and buggy in a few rare situations, but using an external keyboard is definitely worth it for Pythonista.
Just so you know, I didn't get the keyboard specifically for my iPad or Pythonista. I just happened to have it and decided to use it for my iPad and a full wired keyboard for my computer. I can't say much about any alternatives, though I do recommend getting a normal-sized keyboard. There are some display covers with integrated keyboards that are smaller or lack certain keys. If you're used to normal keyboards those aren't very useful in my opinion, I keep hitting the wrong keys if the keyboard has an unusual size or layout.
-
is there a software like pythonista that does C code as well? just wondering.. And thanks for that never thought about using a regular apple keyboard
-
@SuperMiguel C code would need to be compiled so no go on ipad. For keyboards, I've always had good luck with the belkin keyboard cases.
-
@briarfox, I guess it is possible to write a virtual machine in Python, which will execute C code. That would require you to build your own C compiler to compile for this virtual machine tho... I had this idea before, but it seems too hard for a single person to implement.
-
Another approach http://www.dmitry-kovba.com you write apps on your iPad but they are compiled and run in the cloud.
-
As far as I know nobody has written a C compiler or VM in Python yet, which is unsurprising because most of the Python community uses normal operating systems that have a C compiler built-in. Though I think I have a semi-functional C preprocessor somewhere in my script library. Compared to an entire C compiler that seemed much more realistically feasible.
The main problem with running C using Python is that it is practically necessary to simulate raw memory, else anything that uses
malloc
or memory access-reliant dark magic will fail. The best way to do that would be either using abytearray
or possibly amemoryview
of abytearray
. In any case it would be far from efficient.(Interestingly the discussion topic changed in under five hours from wireless keyboards for iOS devices to writing a Python-based C compiler.)
-
You could cheat and pick up a $35 raspberry pi, write the code in textastic or ssh/vim and run it in a console.
@dgelessus Where's the fun staying on topic :)
-
That is of course an option, but that would be too easy ;) And there's no way to do that with Python modules written in C. But then again it would be even harder to write a C compiler in Python that supports extending Python.
By the way, if anyone is looking for an iOS SSH client, Serverauditor is a good one. It has a few nice features like color support, mapping finger swipes to arrow key presses, an extra keyboard row with modifier keys, and surprisingly good external keyboard support. Very useful when working on stash to quickly check how a real bash does this and that.
-
@dgelessus, more off-topic :]. The speed wouldn't be such a big problem, as I don't think somebody'd be creating bigs apps on an iPad - it is uncomfy to type it on a tablet. And it would allow to (after LOOTS of work time) allow to compile gcc. On the other hand it wouldn't be a lot of use: you wouldn't be able to use graphics && stuff on an iPad.
Regarding the keyboards - I am not a big pro, but a bluetooth keyboard should work, right? If you are feeling like doing lots of programming you could research about bluetooth keyboard and write one on Python. It'd run on PC, detect key presses and send them over bluetooth to an iPad :]
-
@dgelessus: You probably have seen this, but if not: Check about Fabrice Bellard's jslinux page. He wrote an <a href="http://bellard.org/jslinux/">entire x86 hardware emulator</a> in Javascript(!)...that boots an embedded Linux Kernel. He even includes gcc so technically one could compile C on the ipad by having the jslinux VM running in a local WebView in Pythonista or something, but that's just being silly :-). At this stage it's really more of a curiosity and a toy, but there are more than a couple of C-to-JS compiler projects out there that basically treats JS as sort of a machine-instruction layer.
On a semi-related note: Has anyone gotten PyEmu to run successfully under Pythonista? (It isn't a full system emulator for booting an OS or anything -- it's primary an x86 emulator for debugging/stepping through routines for reverse-engineering/analyzing malware, etc.). It appears to have a dependency on a disassembler module that must be compiled but I'm wondering if another pure-python disasm module could be dropped in.
And just so I'm contributing to the original spirit of the thread. The best BT iPad keyboard I've ever used was a ClamCase Pro with my iPad 4th gen (iPad2 will also fit perfectly). But with my new iPad Air 2 I really wanted a black case that was lightweight (the ClamCase is only available in white and nearly doubles the weight of the iPad). This time I went with a Logitech Type+ which is proving to be a great choice. Hint: Be sure to check for standard key placement (if that's important to you). I was looking at a couple of other popular iPad keyboards but they had funky key placements (with the Ctrl or semicolon key placed to the right of the spacebar, etc) which immediately disqualified them for my use.
-
Ditto on the Logitech Type+. Had the Belkin. POS (not point of sales). Dropped out ALL the time. The Logitech has been rock solid.
-
@pacco, there's also asm.js, which is a subset of JavaScript intended for easy optimization. It is based on concepts like implicit type annotations (e. g.
i = i|0
is a no-op that ensures thati
is an integer, because a bitwise op would fail otherwise) to make the very weakly typed language easier to compile into low-level code relying on strong and/or static typing. There's also a C-to-asm.js code translator, which has already been used to run fairly large software like CPython and the Unity 3D engine. Apparently Mozilla are even working on an optimized asm.js engine that we'll presumably find in Firefox at some point.@omz, would it be possible to split the C-related posts into a different thread? Sorry for going so far off-topic, but this is an interesting discussion.
-
On the original keyboard thread: I also had a Zagg Folio that I bought about the same time as my new iPad. Nice keyboard, athough not quite as sturdy as the ClamCase. However, it had a standard key layout, a hinged design (that gave it the laptop-like formfactor I'm fond of) and it came in black!
Unfortunately, after about two months of use it broke and literally split apart at the hinge area. This wasn't entirely a suprise as I hadn't been too impressed with the build quality (i.e., it felt flimsy) when I got it.
In all fairness, I should add that I'm a pretty heavy iPad user and probably opened/closed that case at least a dozen times daily, for those two months.
@dgelessus : Yes, thanks -- those were some of the projects I was alluding to. Another is Emscripten, an C-to-JS compiler. Amazingly, there is a project that ported DOSBox to JS using this tool. I'm too new to the Python world to know if something like this has been attempted/possible with this language, but I'll admit to wondering if other compilers could be built to generate compatible bytecode that Pythonisa could execute. (Much like the way the JVM and CLR supports multiple languages).
-
If you need a portable keyboard, I like the iWerkz folding keyboard. It takes a little getting used to if you’re a touch-typist due to the gap where the fold is, but it is very easy to carry around and reasonably solid for what it is.
If your need isn’t portable, I absolutely love the Logitech K760. It’s solar-powered, and has three bluetooth identifiers, chosen by three buttons up top. So, right now I’m typing on my iMac using it; if I take it onto the porch, I hit the second button and it it pairs with my iPad; occasionally I use it with my iPhone by hitting the third button. As far as the Mac, iPad, and iPhone are concerned, it’s three different keyboards, so they never conflict when one device happens to be near another device when I turn the keyboard on.
-
Apologies for continuing the 'contamination' of this thread (ostensibly about iPad keyboards!)
Below is something I used to convince myself that Pythonista could run 'bytecode binaries' (i.e., .pyc) files even if it didn't produce them. It's a short .pyc file created using a mini-assembler that emits Python bytecode. So in effect, yes -- if someone were sufficiently motivated they could conceivably write another language compiler to emit bytecode files that Pythonista could execute. (Much like how the JVM or CLR allows this as mentioned in my earlier comment). I'm not sure what the point would be from a practical perspective. But some things are fun simply because they're possible, I suppose.
Anyway, apologies again if this isn't exactly news to the experienced Python hackers here. As I've said before, I'm new to this language and cobbling together snippets of test code has always been my preferred way of learning.
Thanks,<br>
PaccoReminder: The Pythonista file navigator doesn't display .pyc files. Use shellista or some other tool to see them.
<pre><code>
A proof-of-concept to illustrate that Pythonista can call/run bytecode (.pyc) files
that have been precompiled (no surprise) or even created using other tools.
Pacco 20150114
import os,base64
A bytecode binary created using the bytecode assembler [https://github.com/pib/papaya]
and patched to use Pythonista 1.5's identifier [03f3] in first two bytes.
[http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html]
This is just the Fibonacci (fib.pya) example included with the Papaya assembler
pycbin=base64.b64decode(
'A/MNCr7JtlRjAAAAAAAAAAABAAAAQAAAAHMNAAAAZAEAhAAAWgAAZAAAUygCAAAATmMBAAAAAQAAAAQA'+
'AABDAAAAcz4AAAB8AABkAQBrAgBvEABkAQBTAXwAAGQCAGsCAG8hAGQCAFMBdAAAfAAAZAIAGIMBAHQA'+
'AHwAAGQDABiDAQAXUygEAAAATmkAAAAAaQEAAABpAgAAACgBAAAAdAMAAABmaWIoAQAAAHQBAAAAbigA'+
'AAAAKAAAAABzBwAAAGZpYi5weWFSAAAAAAQAAABzMgAAAAMBAwEDAQMBAwEBBAEBAwEDAQMBAwEDAQEE'+
'AQEDAQMBAwEBAQMCAwEDAQMBAQEDAQECKAEAAABSAAAAACgAAAAAKAAAAAAoAAAAAHMHAAAAZmliLnB5'+
'YXMIAAAAPG1vZHVsZT4CAAAAcwgAAAADJQMBAwEDAQ=='
)write it to a .pyc file
pycfile='fib0.pyc'
with open(pycfile,'wb') as f:
f.write(pycbin)Now load and call a function in the binary
import imp
try:
ourpyc=imp.load_compiled('Test Module',pycfile)
print ourpyc.fib(10) # call a function in our loaded pyc file
except Exception as e:
print "Error:",eclean up .pyc afterwards to be neat
if os.path.isfile(pycfile): os.remove(pycfile)
</code></pre>