Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 8th, 2006, 7:52 PM   #1
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 115
Rep Power: 3 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
Combining strings for os.system()

Not working too well >_>

import os

map = raw_input("Enter map name: ") # ex. Town
gunzrun = "\"C:\\Program Files\\MAIET\\OldGunz\\GunzRunnable [02-06-06].exe\"" # (exe is C:\Program Files\MAIET\OldGunz\GunzRunnable [02-06-06.exe)
game = " /game \"" # the "/game" switch
eq = "\"" # quote mark at the end

full = gunzrun + game + eq
# after it's done, it turns out to be "C:\Program Files\MAIET\OldGunz\GunzRunnable [02-06-06].exe" /game "mapname"

os.system(full)

Output is:
'C:\Program\' is not recognized as an internal or external command, operable program or batch file.

Works right till then, how do I make the space in the string work?
__________________
How do you play Religious Roulette?
Stand around in a circle and blaspheme till someone gets struck by lightning.
peaceofpi is offline   Reply With Quote
Old Sep 8th, 2006, 11:33 PM   #2
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 115
Rep Power: 3 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
Bleh, nevermind. I turned to VB (lol) and got a working GUI program for it
__________________
How do you play Religious Roulette?
Stand around in a circle and blaspheme till someone gets struck by lightning.
peaceofpi is offline   Reply With Quote
Old Sep 9th, 2006, 9:00 AM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
full = gunzrun + game + eq + map + eq

That's what you want.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 9th, 2006, 2:45 PM   #4
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 115
Rep Power: 3 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
Oh wow, thanks. I'd have never realized it, teehee
__________________
How do you play Religious Roulette?
Stand around in a circle and blaspheme till someone gets struck by lightning.
peaceofpi is offline   Reply With Quote
Old Sep 9th, 2006, 4:56 PM   #5
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 928
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
You should use os.path.join for this task to make your code (more) portable.

You should also use a Popen object from the subprocess module rather than os.system for the same reason.

You could also, as a matter of preference, prepend your paths with r to create raw strings so that you don't have to escape backslashes (unless the last character in the string is a backslash, in which case it must be escaped).
titaniumdecoy is offline   Reply With Quote
Old Sep 9th, 2006, 6:13 PM   #6
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Since the Python code is running an exe file, I doubt portability matters.
Arevos is offline   Reply With Quote
Old Sep 13th, 2006, 9:15 PM   #7
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 928
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
C++ code runs in an exe file, so I suppose portability doesn't matter there, either?

Last edited by titaniumdecoy; Sep 13th, 2006 at 9:34 PM.
titaniumdecoy is offline   Reply With Quote
Old Sep 13th, 2006, 9:24 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You suppose right. Portability doesn't matter with an .exe file -- it's generally already blown to hell and gone. Portability is primarily a source code phenomenon. What good is a highly portable adjunct that runs completely non-portable code, regardless of the executive mechanism?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 13th, 2006, 9:36 PM   #9
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 928
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
"The good" is that it's easy to compile the source code to formats that will run on other systems. It may not matter at present, but if a port becomes desirable in the future, the code won't need to be rewritten.

Besides, it's good practice; why not use deprecated functions if doing so will have no effect on the compiled executable?
titaniumdecoy is offline   Reply With Quote
Old Sep 13th, 2006, 10:17 PM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I'm glad you 'splained that fer me. :beard:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining Values in an array bigmitch C++ 4 Feb 10th, 2006 8:29 AM
inserting strings into other strings codylee270 C 2 Dec 3rd, 2005 10:37 PM
Question about multidimensional arrays of strings aznluvsmc C 8 Oct 15th, 2005 11:20 PM
Passing strings from a C++ DLL to VB tam10 C++ 0 Sep 16th, 2005 6:52 PM
pointers strings, and strcat() conbrio C 3 Apr 16th, 2005 2:23 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:48 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC