Is it possible to program a module? Or even import it?
If so, how?
Forum Archive
Custom Module
- Put your code into a module called
reefrunner(Pythonista will add the.pyfor you). - In your main program add the line:
import reefrunner ; reload(reefrunner). - In your main program you can now use classes, functions, and variables defined in reefrunner.
The reload() command above is strongly advised for modules that you are editing to ensure that Pythonista is always using the latest and greatest code.
Thank you very much
I get an error that says no module named reefrunner
Never mind I figured it out
Ok another question.
import ReefRunner ; reload(ReefRunner)
gac = raw_input(' ')
def graphics():
gbox=''' |-------------------|
| |
| |
| |
| |
|___________________|
'''
if gac == 'graphics.gbox()':
print(gbox)
else:
print('The Text You Entered Is Not Compatible With This Module')
It says gbox is not defined. What do I do?
In your code above, the scope of gbox is only inside of the function graphics().
If you indent the if statement to be inside of the function graphics(), and you call graphics(), it should work.
Thanks! Your super helpful! Are you like a moderator?
As far as I know only @omz (developer of Pythonista) has admin rights on the forums. @ccc just has a good amount of experience with Python. (Not as if this forum would even need moderators. Unlike a few other places on the internet, this is a very friendly and civil forum.)
I indented the if statment. But now it won't even print the box. I get no errors
You must call graphics() to run its code.
How do I call graphixs()
See the last line:
import ReefRunner ; reload(ReefRunner)
gac = raw_input('Type "grapics()" or not.: ').lower()
def graphics():
gbox=''' |-------------------|
| |
| |
| |
| |
|___________________|
'''
if gac == 'graphics()':
print(gbox)
else:
print('The Text You Entered Is Not Compatible With This Module')
graphics() # here we are calling graphics() to run the code of that function
Ok thanks. Sorry that was a noob question