def statedFunction(): """This function writes a string to a file and returns a predefined string returns "this creates state" """ f=open("bug",'a') f.write(" My help call just created state on disk") f.close() return "this creates state" def foo(bar=statedFunction()): """ returns bar appended with as. bar the thing to append as to defaultes to a stated function """ return "%s as"%bar