| 1 | initial version |
Note that the Sage console is using IPython. This question on stack overflow leads to the following trick
def func()
print('Hello!')
if __name__ == '__main__' and '__file__' in globals():
func()
(does work for me with both %runfile and %attach)
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.