![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
hi: for(;;) goto hi;
|
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. |
|
|
|
|
|
#2 |
|
hi: for(;;) goto hi;
|
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. |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
full = gunzrun + game + eq + map + eq That's what you want. |
|
|
|
|
|
#4 |
|
hi: for(;;) goto hi;
|
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. |
|
|
|
|
|
#5 |
|
Expert Programmer
|
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). |
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Since the Python code is running an exe file, I doubt portability matters.
|
|
|
|
|
|
#7 |
|
Expert Programmer
|
C++ code runs in an exe file, so I suppose portability doesn't matter there, either?
Last edited by titaniumdecoy; Sep 13th, 2006 at 8:34 PM. |
|
|
|
|
|
#8 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#9 |
|
Expert Programmer
|
"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? |
|
|
|
|
|
#10 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Combining Values in an array | bigmitch | C++ | 4 | Feb 10th, 2006 7:29 AM |
| inserting strings into other strings | codylee270 | C | 2 | Dec 3rd, 2005 9:37 PM |
| Question about multidimensional arrays of strings | aznluvsmc | C | 8 | Oct 15th, 2005 10:20 PM |
| Passing strings from a C++ DLL to VB | tam10 | C++ | 0 | Sep 16th, 2005 5:52 PM |
| pointers strings, and strcat() | conbrio | C | 3 | Apr 16th, 2005 1:23 PM |