running a shell command from a python program
Hi, I'm a newbie, so please be gentle :-) How would I run a shell command in Python? Here is what I want to do: I want to run a shell command that outputs some stuff, save it into a list and do stuff with the contents of that list. I started with a BASH script actually, until I realized I really needed better data structures :-) Is popen the answer? Also, where online would I get access to good sample code that I could peruse? I'm running 2.2.3 on Linux, and going strictly by online doc so far. Thanks! S C -- http://mail.python.org/mailman/listinfo/python-list
Re: running a shell command from a python program
Doh, use the search Luke: http://www.wellho.net/forum/Programming-in-Python-and-Ruby/Running-shell-commands-from-Python.html Seems like popen is the way to go. S -- http://mail.python.org/mailman/listinfo/python-list
looking up dictionaries by values
Hi there, I'm still a bit new to Python, and had a question. I have a dictionary that looks like: PWD = \ { "root": 0, "joe": 200, "susan": 201, .. } In other words, the values are unique as well as the keys. I've run into a situation where I need to lookup the item by value. So given 201, I need to say the key is really susan. Is there a way to do this that does not traverse the entire dictionary multiple times? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: tutorial
I'm a beginner as well, and I liked this one: http://docs.python.org/tut/tut.html But I ended up buying the "Learning Python" book anyway. -- http://mail.python.org/mailman/listinfo/python-list