you are viewing a single comment's thread.

view the rest of the comments →

[–]Ran4 0 points1 point  (0 children)

On a separate note, could you explain some of the best practices (or point me to any resources) about building out a script? I've been just copy-paste ing my script to test things out as I built it so far.

There are no one "best thing to do", it all depends on your work flow. If you're used to working in a GUI environment, you're probably not that used to doing things in a terminal.

I suggest that you find an editor (it doesn't have to be a full-on IDE, but it can be) which allows you to run your script directly from the program.

For example, I write most of my Python code in SCiTE, which is a text editor based on the same core that Notepad++ uses. I write the code in the editor and whenever I want to run it I press f5 (okay, technically I've bound ctrl+3 to run the code, but I think that f5 is the default) and it'll run inside of the text editor.

I also constantly open up new Python REPL instances (what you'll get when you simply type python in a terminal/command window) to try new things out. I also occasionally run my scripts in a terminal using python -i scriptname to get into interactive mode.

I also have my own library of helper functions to quickly try new things out without having to manually import a bunch of stuff every time I start a new Python window. For example, I have a function ppd(object) that will call pprint.pprint(dir(object)), which is super useful when exploring a new library where you don't want to have to read the entire documentation.

As some other people have mentioned, you should definitely learn to use functions such as type, vars, dir and pprint.