execute python function from terminal

If you have a python file: myfunction.py

def hours_to_minutes(minutes):
  hours = minutes / 60.0
  return hours
<span 				data-mce-type="bookmark" 				id="mce_SELREST_start" 				data-mce-style="overflow:hidden;line-height:0" 				style="overflow:hidden;line-height:0" 			></span>

Then you can execute it with:

python -c ‘from function import *; print(hours_to_minutes(20))’

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.