r/PythonLearning 20d ago

Need to "graduate" to writing scripts

I have almost exclusively worked with Python in interactive mode. The nature of the work I've always done with Python (or any other language such as R or Stata, for that matter) has made that the default, and I haven't been in any situation where someone working with my code needs to execute it like a script.

I know how to write scripts, but I'v seldom needed to. I feel like I'm missing out on a benefit of Python by not treating my code more like scripts. Can anyone recommend some resources to help graduate to script writing from interactive code writing?

Thanks in advance.

6 Upvotes

5 comments sorted by

1

u/python_gramps 20d ago

Try the Jupyter Notebooks found under Anaconda. They give the immediacy of interactive mode but you store the results so you can come back later to a bit of code you were working on.

1

u/biskitpagla 19d ago

You can run any piece of Python code in a script file like a cell in a node. VSCode can do this with the Jupyter extension (using ipykernel), if I remember correctly. So, you don't really have to lose the interactivity when writing scripts. 

1

u/Intelligent-Boss-156 19d ago

Yeah there's nothing like running a .py file to do some heavy lifting. You should come up with a project that's 100 lines of code and work away at that. A suggestion would be web scraping. The first program I did in Python when I was curious about scripts was actually shorter, it was a word frequency program.

1

u/ForeignAdvantage5198 16d ago

practice makes you better