473,324 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Needing a WinXP Python variant of a line of code

I have this line of code that's written with Linux in mind:

path_to_nethack_logfile = os.popen("locate logfile | grep
nethackdir").read()

and I'm wanting a Windows equivalent, any suggggestions?
Thanks.

CronoCloud (Ron Rogers Jr.)
Jan 30 '06 #1
2 926
import os, os.path

path_to_nethack_logfile = ""
for root, dirs, files in os.walk("c:\\"):
if 'nethackdir' in root:
logs = [x for x in files if 'logfile' in x]
if len(logs) > 0:
path_to_nethack_logfile = os.path.join(root, logs[0])
exit

Ron Rogers Jr. wrote:
I have this line of code that's written with Linux in mind:

path_to_nethack_logfile = os.popen("locate logfile | grep
nethackdir").read()

and I'm wanting a Windows equivalent, any suggggestions?
Thanks.

CronoCloud (Ron Rogers Jr.)

Jan 30 '06 #2
John Zenger wrote:
import os, os.path

path_to_nethack_logfile = ""
for root, dirs, files in os.walk("c:\\"):
if 'nethackdir' in root:
logs = [x for x in files if 'logfile' in x]
if len(logs) > 0:
path_to_nethack_logfile = os.path.join(root, logs[0])
exit


Thank you. I guess I should do more reading, since I hadn't read about
os.walk yet. I shouldn't even be trying to do what I'm doing so early in
my learning. It will eventually be a Nethack logfile parse script.
CronoCloud (Ron Rogers Jr.)
Jan 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Matt Smith | last post by:
Hi, all. Just a quick question, when setting a COM process to read a value from a pre-defined register index, I think, I have to change the variable that the value will be returned to (as I have...
2
by: Eric Woudenberg | last post by:
I just installed a Python 2.3.4 Windows binary on a friend's WinXP machine (because the latest Cygwin-provided Python 2.3 build leaves out the winsound module for some reason). When I try and...
1
by: George Carman | last post by:
Please excuse the following mailing, I do not have access to a news server and cannot post to comp.lang.python. I recently installed Python 2.3.4 on WinXP. Command line interpreter works fine...
3
by: sidanko | last post by:
I use Python 2.3.3 (Enthought edition) with wxPython and it is installed on both WinXP and Win98. On Win98 machine I have the following error:...
0
by: Andrew Ayre | last post by:
Hi, I can't seem to get the library built, and any help is greatly appreciated. Here is the info: Windows XP Borland C++ Builder 5 Latest Boost source code (downloaded at the weekend) Windows...
2
by: Gigs_ | last post by:
Is there any way to convert ocaml code to python? but not manually thx
5
by: vml | last post by:
I have a python com object which contains a method to inverse an array in vb 6 the definition of the class is : class Fop: _public_methods_ = def SqVal(self,*val): #vol=(val,val)...
30
by: Ivan Reborin | last post by:
Hello everyone, I was wondering if anyone here has a moment of time to help me with 2 things that have been bugging me. 1. Multi dimensional arrays - how do you load them in python For...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.