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
-
@wnMark said:
I tried to run some programs with 3000001, but I failed in some cases.
After fixing the errors, I tried to run a program, but it didn´t start and I also get no error message.
Then I tried to provocate some errors and deleted some double points and after I get the error hint, I added these double points back. And so I go down in the listing and suddenly the program starts.
Some hints?
In the meantime I was able to migrate my biggest Python program to Python 3.x (and it still runs on Pythonista 2)
- print must have brackets now: print ("Hello world") instead of print "Hello world"
- Unequal must be != instead of <>
- Und I must divide 10//5 instead of 10/5 to get 2 and not 2.0
So far so good. But the last point was a little bit more tricky
4. Some (not all) spaces instead of tabs prevent the program to run. But there was no hint or error message! If hope there will be a hint in next version! -
-
@omz In Python 2 you could write
<>
instead of!=
, I think that's what @wnMark is referring to.Also, more issues - when I use Pythonista 3 for a while (15 minutes or so?), it starts reacting slowly and crashes shortly after. I'm not exactly working with huge files - I have one tab with a short 5 line file, and a second one with an "average" Python file (stash's
system/shio.py
), and other than that I check things in the console and the Python docs every now and then. I don't have any such issues in Pythonista 2. My device is an iPad mini 1 running iOS 9.2.1 and I'm using an external Apple wireless keyboard.Other minor issues:
- The syntax highlighter considers the
u
prefix ofunicode
literals (as inu"üñìcødé"
) part of the string, but not theb
prefix ofbytes
literals (as inb"PK\x03\x04"
). - In the interactive console, the tab key on hardware keyboards does not expand the first autocompletion suggestion, unlike in the editor.
- The syntax highlighter considers the
-
@dgelessus , just as a side note. I read somewhere not to use the operators in Python unless some syntax requires it. Use 'not' instead. Was simple advice, but almost never need to use the in equality operators.
-
Using
<>
really is not recommended, it was only kept for bachward compatibility with Python 1. I have never seen any actual Python code use it. Though I don't see what's wrong with!=
. Would you rather writenot option == "default"
instead ofoption != "default"
? And would you writenot option is None
rather thanoption is not None
? -
@dgelessus , I would take option is not None. But when starting Python I was thinking c. So != && <> kept popping up in my mind
-
@wnMark said:
- Some (not all) spaces instead of tabs prevent the program to run. But there was no hint or error message! If hope there will be a hint in next version!
I am fine with != instead of <>
But the issue are the spaces, that prevent the program to run
-
Python 3 is a little more picky when you use tabs and spaces in combination, and rightfully so. The issue when you mix tabs and spaces is that while a space has a fixed width (one character), a tab does not. Some people say tabs should be 8 characters, some say 4 or 2. This means that when you use spaces to indent one line and tabs to indent the next, everything will look fine to you, but someone else with a different tab width, or the Python interpreter, will be confused.
In Python 2 I think it was assumed that tabs are equivalent to 8 spaces, in Python 3 this was changed. Now tabs are considered a different type of indent that is not equivalent to any number of spaces. You can still mix tabs and spaces (but please don't) as long as it doesn't contradict any previous indentation. For example this is valid Python 3 (
\t
represents a tab):if True: if True: \tprint("works")
But this is not:
if True: if True: \tprint("doesn't work")
Normally Python 3 should raise a
TabError
for the second script, but for some reason that doesn't happen in Pythonista. -
You can't stop the script if an input() is running
-
Also why does webbrowser open MobileSafari and not the inapp browser?
-
Got the new Beta, all the issues I reported are already fixed, thanks a lot for the quick turn around
-
Thanks for the feedback, everyone!
I've just uploaded a new build (300003) to address a lot of the bugs you reported. See the release notes in TestFlight for details.
The syntax highlighter considers the u prefix of unicode literals (as in u"üñìcødé") part of the string, but not the b prefix of bytes literals (as in b"PK\x03\x04").
In the interactive console, the tab key on hardware keyboards does not expand the first autocompletion suggestion, unlike in the editor.
I have both of these on my todo list. Haven't looked at the double
~~
issue yet. -
async
,await
andnonlocal
are only suggested in the editor, not the interactive promptnonlocal
is also missing syntax highlighting- Exceptions are only suggested in the interactive prompt, not the editor
-
async, await and nonlocal are only suggested in the editor, not the interactive prompt
True, I actually doubt that these will see much use in the REPL though.
nonlocal is also missing syntax highlighting
Ah, missed that.
Exceptions are only suggested in the interactive prompt, not the editor
Works for me. Note that exceptions are only suggested after the
raise
andexcept
keywords though (would add too much clutter otherwise, especially as there are a lot more built-in exception types in Python 3). -
@omz said:
Works for me. Note that exceptions are only suggested after the
raise
andexcept
keywords though (would add too much clutter otherwise, especially as there are a lot more built-in exception types in Python 3).Ah okay, I just typed somewhere in a file and they didn't come up. To be honest I'm not a big fan of hiding things that the user "probably" won't need - I understand that all the exception names clutter up the suggestions, but what if I do want to use an exception in a non-"normal" place? What if I want to extend an exception class, or do an
isinstance
check, or anassertRaises
, or create an exception without raising it right away?Now I noticed that Pythonista 2 behaves the same way. I always thought that exception names were never suggested and that it was a bug related to how they are avaliable both as builtins and via the
exceptions
module.At the moment the autocompletion ignores case completely, perhaps it would help with the clutter if casing was taken into account. Or change the ordering of names based on whether their case matches what was typed - so (assuming you did
import sys
previously) if you typesy
you getsys
,SystemError
,SystemExit
, but when you typeSy
you getSystemError
,SystemExit
,sys
. -
@dgelessus said:
At the moment the autocompletion ignores case completely, perhaps it would help with the clutter if casing was taken into account. Or change the ordering of names based on whether their case matches what was typed - so (assuming you did import sys previously) if you type sy you get sys, SystemError, SystemExit, but when you type Sy you get SystemError, SystemExit, sys.
Interesting idea, I'll have to think about that.
-
@omz Does Pythonista 3 support Type Hints?
-
@OI You can annotate your functions with type hints if you like (the syntax and the
typing
module are supported), but Pythonista itself doesn't do anything with them. -
@omz
Thank you for updating the Beta3.
Now I was able to migrate a program to Python3 in just a few minutes. And there was a hint if I had mixed Spaces and Tabs!
And the Short-Cuts are back now! -
@wnMark There's an option under the indentation settings to show mixed indentation in the editor, i. e. when you indent with tabs, spaces are made visible, and if you indent with spaces, tabs are made visible.