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.
How to use « def f(...)
ClemRockZ last edited by
I am having and issue, I don’t know how to use the def function on Pythonista because there is no shell.
Can someone explain me just how to make a plain program like this one work ?
Amegon last edited by Amegon
I guess you speak about a beginner question, please correct me if I am wrong.
def ... is used to define a method/function
def <name>([<parameter_name>[, <parameter>]]):
Make sure to have a ':' at the end of your def and to add a defined number of spaces for all lines inside your method.
def f(foo): return foo**2
Either create a new file, enter those lines and press on the play button upper right, or swipe to the right until you are in Console and enter the lines there. Also there you can test your method by writing f(2)
You can also add a print outside method define, this should make sure to make pythonista switch automatically to console view when you execute it (since it would generate an output there)
zrzka last edited by
Here's simple video and __main__ docs. As @Amegon already said, run script via play button.
P.S. There's no shell, but there's StaSh.