Linux shell to python

Barry Scott barry at barrys-emacs.org
Tue Jul 31 18:36:24 EDT 2012



On 30 Jul 2012, at 23:56, Dan Stromberg <drsalists at gmail.com> wrote:

> 
> On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott <barry at barrys-emacs.org> wrote:
> lspci gets all its information from the files in /sys/bus/pci/devices.
>  
> You can use os.listdir() to list all the files in the folder and then open
> the files you want to get the data you need.
> Gee, wouldn't it be more portable to parse lspci?  I wouldn't put it past the (Linux) kernel devs to move the pseudo-filesystems around again...

No. The app is less stable the the linux user api gureentee.
I have been bitten with app output format changes but the /sys files have been
Reliable and far better focused at answering questions.

>  
> And of course you can write list comprehensions on as many lines as
> it take to make the code maintainable.
> Sigh, and I'm also not keen on multi-line list comprehensions, specifically because I think they tend to make less readable code.  It also becomes a mess when you need to insert print statements to get some visibility into what's going on.
> 

With out trading examples of production code this is resolverable.

Barry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120731/4f7f559f/attachment.html>


More information about the Python-list mailing list