0

In this program I have a lot of game directories in a list like so:

base = "C:/Program Files/Game"
expansion  = "C:/Program Files/Game/Expansion"

Games = [(base, "Base Game"),(expansion, "Expansion 1")]
Installed = []

The program then sees if they are installed like this:

for path, name in Games:      #For every path and name in Games list,
        if os.path.isdir(path):     #If the path exists,
            Installed.append(name)  #Add its NAME to the Installed list.      
    print "\n----------- Games Installed ------------"
    for name in Installed: print name

Now it must check to see if a file is in the games that are in the Installed list. If it is not there, the name of the game must be printed and the file copied to the game's directory.

for path in Installed:
        if not os.path.isfile(path + "d3dx9_31.dll"):
            Ok = False
            print "DLL not found in %s. Installing..." % name
            shutil.copy2(programRoot + "d3dx9_31.dll", path + "d3dx9_31.dll")
            
            if os.path.isfile(path + "d3dx9_31.dll"): print "DLL sucessfully installed.\n"    
            else: raise NotFoundError("Couldn't find DLL after copying to %s" % name)
            #Custom error class

In order for that to work correctly, the path AND name of the game must be added to the Installed list just like it is in the Games list.


Well that's simple. Just change the second block of code to this:

for path, name in Games:      #For every path and name in Games list,
        if os.path.isdir(path):     #If the path exists,
            Installed.append(path, name)  #Add its path and name to the Installed list.      
    print "\n----------- Games Installed ------------"
    for name in Installed: print name

Nope, nevermind. That does not work as append takes only one argument! Now I don't know what to do. :(

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by WildBamaBoy
0

You took out tuple and put it in two variables path and name.

Now you only reconstruct it for the single parameter:

Installed.append((path,name))
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.