Importing functions doesn't work on Original IPad running iOS 5.
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.
I tried it and it worked fine. Are you sure that the file, you want to import a function from, is located in your current working directory? Try
import osand then
print os.listdir('.'). Is your file in this list?
@Sebastian, This issue is happening on an original iPad with iOS 5. Is that your environment too?
@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.
Oh, then I'm out of ideas... <br>
Sorry I couldn't be of more help.
Last time I checked, the original iPad and iOS 5 were not supported.
I've entered this thread just because I saw a big entry on the forum's page stating that (i quote) "Importing functions doesn't work!". For the sake of preciseness, i think the OP's original question should be rephrased to "Importing functions doesn't work in original iPad with iOS 5", as the original title could be misleading to someone new to Pythonista.
Pablo, I edited the title. Thanks for the suggestion!
In Pythonista 1.3 and earlier, the interactive console and the editor run in different interpreters.
It can happen that a module that is written in the editor has not been saved yet when trying to import it in the console. Saving will generally happen when a script is run or when a different file is opened.
It can also happen that the imported version of the script is outdated (Python does not automatically reload modules that were imported once, they're cached unless they're reloaded manually).
To work around the file not being saved, try running the module from the editor first (or open a different file).
To work around import caching, you could either use the built-in
reloadfunction, or use
execfileinstead of importing the module.