Reputation: 3247
I want to call a function in another function. Is it how it`s done?
#=========#=========#=========#=========#
def text_file():
filename = 'text.txt'
return filename
#=========#=========#=========#=========#
def show_log(): ## Main log function,
#filename = 'text.txt'
if not os.path.exists(text_file()): # if text.txt does not exists than create one
file(text_file(), 'w').close()
if os.path.getsize(text_file()) > 0: # if text.txt is not empty show the menu
log_menu()
else: # if text.txt is empty
print
print " You have not draw anything yet!"
print
raw_input(' Press Enter to continue ')
return
Upvotes: 0
Views: 271
Reputation: 798526
Same way as anywhere else.
filename = text_file()
Upvotes: 0
Reputation: 2264
Try this, i cleaned up the code a little. Hope it makes sense.
def text_file():
return 'text.txt'
def show_log(): ## Main log function,
filename = text_file()
if os.path.exists(filename) and os.path.getsize(filename): # if text.txt is not empty show the menu
log_menu()
else: # no textfile there or its empty
print
print " You have not draw anything yet!"
print
raw_input(' Press Enter to continue ')
return
Upvotes: 2