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.
Input and quotes
-
Hello everyone,
excuse my ignorance, but I do not understand why Pythonista returns error when, for example, the code is like this:text = input ('enter the text : ') print (text)
If the string typed by the user is not enclosed in quotation marks, Pyhonista says that the string itself is not defined. Why?
Thanks a lot, and excuse me again.
JR
-
In Python3,
input()
is the way to go but in Python2 (like Pythonista) useraw_input()
instead. -
Ops, thank you very much.
JR -
I just thought of something that might actually work (for once). There must be many more Python beginners than who we see on the forums, and lots of them probably don't know how to work with Python 2, only Python 3. What if, to get around Apple's dynamic linking restrictions, @omz added a way to (optionally) automatically use
lib3to2
to convert simple Python 3 code to Python 2 code when the run button is pressed but before the actual execution? I know the 3to2 tool doesn't convert everything, but if you are writing Python 3 code 3to2 can't handle, you most likely are experienced enough to understand the differences between Python 2 and Python 3, right? The option could come with a warning about advanced code just in case, though. Just an idea. :) -
@Gerzer Thanks
-
import six # already works in Pythonista
http://pythonhosted.org/six is another Python 2 and 3 Compatibility Library
-
-
Yeah but... https://docs.python.org/2/library/2to3.html Is part of the Python Standard Library and six is not.
-
The two libraries have entirely different purposes though. (
lib
)2to3
is used to convert Python 2 code to Python 3, whilesix
is a library that makes it easy to write Python code that runs on multiple Python versions without modification.