0

I am new to Python and I came across a useful piece of code (Python recipe) here that I want to run.

I tried installing Python 3.5 and running it using the "python.exe scriptname.py" format but that lands me into syntax errors. Also tried opening the script in a Python IDE and tried running a syntax checker that again flags some errors. The fist error that i get is the the "os" field is not identified. The second one is the missing brackets around the print statement.

But from the multiple comments on the post in the link above, it appears to me that this should run out of the box.

How am i supposed to run a Python recipe? Is it any different from running a python script. I have heard of recipes in context of Chef so i'm not sure if this has anything to do with it.

Dev28
  • 497
  • 5
  • 16

2 Answers2

4

Python recipe comes from here The O'Reilly Python Cookbook

Its only a fancy name for algorithms that come in use frequently in daily life solved in python coding language.

shruti iyyer
  • 260
  • 2
  • 11
  • Do you know where is the "recipe" term appropriately defined in the "The O'Reilly Python Cookbook". I've been quickly looking for this unsuccessfully. – Jaime Hablutzel Apr 14 '20 at 01:06
3

Your guess was right, python scriptname.exe is the way to go. However this script is for a much older version of Python (2.7), you'll need to fix some syntax issues like print(...) instead of print ... to make it run on Python 3.5.

Kos
  • 70,399
  • 25
  • 169
  • 233
  • Thanks. This is what finally worked for me. http://stackoverflow.com/questions/15912063/how-do-i-run-python-2-and-3-in-windows-7/17245543#17245543 This explains how to run a Python 2 script with a Python 3.3 installation. Very handy. – Dev28 Jul 20 '16 at 17:57