Unfortunately, even for a simple function definition, Pythonista does not work reliably. Instead of this app, I would recommend using a Python install on a UNIX computer.
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.
Posts made by Bobk48
-
Importing functions doesn't work on Original IPad running iOS 5.
-
RE: Importing functions doesn't work on Original IPad running iOS 5.
Pablo, I edited the title. Thanks for the suggestion!
-
How do you run a function?
If I create a function def in the editor, how do I run it in the command line window? On a UNIX machine, you can put the function definition in a file in the same current working directory you're running Python in, and then on the Python command line type from func() import *, then call the function with some arguments, and it returns the results. I don't see any way of doing this in Pythonista for iPad. Any help would be appreciated!
-
RE: How do you run a function?
ccc, I'm out of the Pythonista ball game. Best of luck to you! I'm using PyM and Python2.7 on the iPad now, and big Python IDE's like enthought.com's canopy on my Bill, Steve, and Linus machines.
-
RE: Importing functions doesn't work on Original IPad running iOS 5.
@Sebastian, how do I know what the current working directory is for Pythonista on an IPad? In the browser pane, I never create another directory, I put my edited files in the same directory as the samples that come with Pythonista. I don't think it's a directory problem. Remember I had Pythonista on an original iPad with iOS 5. No more, I don't have time to test Pythonista! I have python functions to test. I use PyM and Python2.7 on the iPad now, and big python IDE's on Bill, Steve, and Linus machines.
-
RE: How do you run a function?
ccc here it is( on an original iPad with iOS 5)-
In the editor, I create the following as a file named tester:
def test(n):
print n
Then, in the interactive python prompt window, I type-
from tester import test #sometimes works, sometimes doesn't
test(5)#always get a name undefined error here
I've tried rebooting the iPad, deleting the file and using another name, but I don't know if you can restart the interpreter. Using multiple imports from the same file could cause a problem, but I don't know how since I use different file and function names each time!
-
RE: How do you run a function?
ccc I did exactly what you recommend, put a simple function definition in the editor, named it without the .py extension, imported the file, called the function, and it gives errors! I put the same file into my UNIX current working directory, and imported it, called the function in it, and it works. I also downloaded 2 other Python IDE's to my iPad- PyM and Python2.7. Used the same file and function definitions in them, and both worked perfectly. And we're not talking some 350 line file, it's a 3 line function def that's good Python. There's something wrong with Pythonista for iOS 5, maybe even 6. But I'm not buying a new iPad for $500 to test out Pythonista for iOS 7!
If it doesn't cost me another $7, I will try reloading Pythonista. And experiment again, but I want to test Python functions, not Pythonista. I gave it 1 star out of 5 on the app store. Sorry! -
RE: How do you run a function?
ccc, your explicit instructions worked perfectly, but for a simple function def in a file named test like-
def testr( n ):
print n
On the interactive command line I enter: from test import testr . It likes that, sometimes.
Then: test(4)
And it gives me a name error!Thanks for being so helpful though!
-
RE: How do you run a function?
ccc, thanks for answering this question! Where you say " put the following in a Pythonista file called 'hello_file' ", how do you do that in IPad Pythonista? I've searched all the button and menu choices in the editor, browser, and command line windows, and there's no file save choice! In the browser, you can create a new empty file for use in the editor window, but I guess my question is "Where is that saved, so to speak?". It seems like editor and command line are disconnected on the IPad. When something is in the editor window, and you press the Run button, it runs that stuff, but where are the files themselves? iPad is not a computer, you have no access to the file system( unless you jailbreak it, I guess.). Any help you could give me on how to save what's in the editor window would be greatly appreciated! Thanks again.
Robert M. Koretsky