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.
Python 3.x Progress Update
-
@Webmaster4o It's definitely possible, and I've actually experimented a bit in that direction.
I personally found it a bit annoying, and less useful than I originally thought. The problem is that I usually type more slowly on a touch screen than I would in a desktop IDE, and that often results in warnings and syntax errors that are essentially meaningless because I've just not finished typing yet...
That might also have to do with a lack of UI polish in my implementation of course (it was just a rough prototype), and I'll probably continue experimenting with this.
-
Agree with @omz regarding "real-time linting". It always feels unnecessary to me - when I'm typing in a line, it should not be checked, because obviously it's not complete yet. And even checking the line after moving the cursor can be too early, sometimes I change other code before I finish typing my current line, for example to add an
import
. -
Speaking of.... it would be nice if the console auto-complete was in some sort of background thread, or is delayed/cancelled by typing. In the console, especially, on my Ipad3 things really slow to a crawl when dealing with complex objects. A classic case,
requests
response objects take 3 or 4 seconds after typing a period before i can keep typing. -
@omz, maybe something has been mentioned along these lines before. But given you have now managed to get both versions of Python running in the same app, can understand it will be just a matter of time before the 2.xx app goes away. For good reason of course. But it also has some great testing potential/advantages.
Could you possibly release a server version of Pythonista that could still share the same sand box as you are doing now with the 2 versions? Extra income for you and an excellent testing Environment for us.The diff between the apps could be one integer somewhere.
Food for thought 😱 -
@JonB I haven't been able to get stash to work. Fixed a bunch of python3 incompatibilities by running 2to3 over it, but I still can't get a functional command line from it.
-
For python3, you would start with the py3 branch of stash. Some things are still incompatible, such as the git command, whose dependencies are not py3 compatible.
I would suggest simply putting #!python2 at the start of launch_stash.py, to force stash to use the python2 interpreter. you can still keep your default interpreter as py3, but run stash using py2.
-
@omz glad to hear the theme, line number and other features will make it over to 2 as well!!! That was half of my feature ask list :)
-
@Oscar said:
On the donation/financial contribution topic. I can understand that @omz feels uncomfortable taking donations, this brings notions of charity. But me and many other are more than willing to contribute financially to the apps, to show appreciation for this wonderful tool and to help with/speed up future development. If there would be an anti-sale day for the new Python 3 version with a higher price (5x?) I would buy it that day.
I agree. I think what this may translate into is that there are some people willing to pay more than what you charge. Since everyone appreciates the single price model and features being available to all, we want to find a way to invest in Pythonista - to show appreciation and support the pace at which you innovate and keep the app around for a long time!
I'm starting to write a lot of scripts for pythonista and soon it will be a cornerstone of my iPhone experience. I already use it as my mobile notepad, ios workflow automation, custom extensions that make using my phone wayyyyy more efficient and save me a lot of time - clicks/select/click/launch/app/click/paste etc. becomes share and click or just click homescreen shortcut.
-
Maybe it's been reported, a lot in this thread.
It appears that the editor is not showing the iter functions for dicts.
Eg, if I do kwargs. In the editor No iteritems is in the list. -
If you're using Python 3 for your script,
dict
s have noiterwhatever
andviewwhatever
methods. The normalwhatever
methods now all return lightweight "views" likeviewwhatever
did in Python 2. -
@dgelessus , ok thanks. My default interpreter is set to 2.7. But it explains what is happening. Guessing it's not the wanted behavior in this case
-
@JonB It occurred to me I could run it in python2 now that the beta supports both. Then it occurred to me that I could run the old dropbox module using python2 (until dropbox deprecate it at least), so I tried that and got it working. Win. Thanks for your help.
btw, I tried pip install dropbox in stash under 2.7, but it didn't work. It seemed to complete the install, but I still got the same errors from the dropbox sync script (under 3.5), I'm guessing pythonista keeps seperate modules for the two versions or something? I'm not too fussed because I have a working solution now, but I figured it was worth mentioning.
-
yes.. python3 has a different site-packages. You can copy the folder in stash
-
@JonB said:
I would suggest simply putting #!python2 at the start of launch_stash.py, to force stash to use the python2 interpreter. you can still keep your default interpreter as py3, but run stash using py2.
This is probably a much better solution than porting the whole thing to py3?
A follow-up question is : how can stash run a python script with the other Python interpreter (3.5) while stash itself is running in 2.7? Or vice versa, what if stash is running with Python 3.5 and the script has a python2 shebang?
Currently stash just uses the
exec
function to run a python script which does not seem to honour the shebang. I'd guess this is possible withobjc_util
, but I am not sure where to start. Any tips are appreciated.Maybe @omz can provide a formal API to allow this kind of cross interpreter call?
-
The editor delegate (_editor_pythonista._get_editor_tab()) has a few new methods
void runScriptAtPath_withInterpreterVersion_arguments_( object, int, object ) void runScriptAtPath_withInterpreterVersion_scriptForShebang_arguments_( object, int, object, object ) void runScriptWithNonDefaultPythonVersion( )
i have used the last, which runs the current editor script in the other interpreter, but not been able to get the first two working. (Though I now think this maybe runs the current script with a different path, as opposed to running a different script)
I suspect exploring the wrench menu might yield some clues, but i have not done that yet.
There is also a PythonInterpreter
ObjCClass('PythonInterpreter').sharedInterpreter()
which looks promising, but i have not explored. -
oh, i see,there is also a PA3PythonInterpreter which provides access to the p3 interpreter. I have not yet tried any of the runScript commands, I assume they take an NSURL.
>>> print_methods('PA3PythonInterpreter') PA3PythonInterpreter Class Methods______ object sharedInterpreter( ) _______Instance Methods______ object completionsForREPL_( object ) object defaultPythonPath( ) void dispatchBlockOnInterpreterThread_( @? ) void doDispatchBlockOnInterpreterThread_( @? ) void doJediCompletion_( object ) object documentsDirectory( ) void evaluateLineInteractively_( object ) object filteredCompletions_withPrefix_( object, object ) object init( ) char interpreterReady( ) object interpreterThread( ) void jediComplete_( object ) object jediThread( ) object libPath( ) void pythonInterpreterTimerAction( ) void runLineWithOptions_( object ) void runScriptWithFileAtPath_argv_( object, object ) void runScriptWithOptions_( object ) char running( ) void setInterpreterReady_( char ) void setInterpreterThread_( object ) void setJediThread_( object ) void setRunning_( char ) void setupInterpreterThreadRunLoop( ) void setupJediThreadRunLoop( ) void startInterpreter( ) void staticAnalysisForScript_completion_( object, @? ) void stop( )
-
@JonB To be honest, I'm not sure if I really want to expose this functionality via Python. I can see a couple of things that could go wrong, e.g. the console's implementation of
raw_input
/input
isn't really prepared for two interpreters running at the same time, and there are probably other issues that I'm not thinking of now.You're right that
PA3PythonInterpreter
is the one responsible for running Python 3.PythonInterpreter
has a slightly different interface (for "historical reasons") and is Python 2-only.runScriptWithFileAtPath_argv_
is its primary method. The path should be a string, and the file should actually exist. argv can be nil/None, otherwise it's a list of strings (the script path is added to it implicitly). Most of the other stuff is internal, and shouldn't be called directly.Edit: One more thing: You shouldn't try to instantiate any of the interpreter classes, they're essentially singletons, use
sharedInterpreter()
to get the global instance. -
Right. The main use case I think would be for stash-- to allow keeping the main codebase written in py2 without having to port everything to six, which has been iffy. on launch we'd maybe launch a worker thread in the py3 interpteter, and then py2 stash could send commands to the py3 worker when encountering a py3 shebang.
-
One bug I noticed is that when you press Tab in the console it will be converted to soaces, regardless of the 'soft-tabs' option.
-
Bug: when running a script via the url scheme (
pythonista3://
) it ignores the default interpreter setting and runs the script as 3.5. It also ignores the shebang -#!python2