So I have been playing with classes, seeing that they are more efficient than globals, and I wrote this hopefully simple test program to see if I properly reverse engineered tetlaw's simple rpg. For the life of me I cannot figure out what is wrong with it. If an expert on classes here could tell me why that would be lovely.

import random
import time

class items:
    def __init__(self):
        self.nametext = ['health potion', 'dagger', '5 gold'] = self.nametext[self._name()]
        self.healthpotions = 0
        self.daggers = 0 = 0
        self.newitem = 0

    def potgain(self):
        if self.newitem == 1:
            items.healthpotions = items.healthpotions + 1
            self.newitem = 0
    def daggain(self):
        if self.newitem == 2:
            items.daggers += 1
            self.newitem = 0
    def goldgain(self):
        if self.newitem == 3:
   += 5
            self.newitem = 0
    def _name(self):
        return random.randrange(3)+1

def playerinv():
    it = items()
    print "Inventory:"
    print "==================="
    print "Gold:            ",
    print "Daggers:         ",it.daggers
    print "Healing Potions: ",it.healthpotions

def invact():
    inv = input('>> ')
    if inv == 1:
    if inv == 2:
        print "Invalid. 1 for exit, 2 for an item."

def randitem():
    global it
    it = items()
    if it._name == 1:
        it.healthpotions += 1
    elif it._name == 2:
        it.daggers +=  1
    elif it._name == 3: += 5
        print "Something has gone horribly wrong"
    print "A faint magical glow illuminates the dark corridor..."
    print "...and",it.nametext,"appears into your hands. It is"
    print "dark once more..."

def additems():
    items.newitem = 1

You have got to give a sample input and a the related output that you are expecting.

Put a main section i.e.

if __name__  ==  '__main__':
    # initialize some vars
    # execute the function with sample parameters
    # show the expected output as remarks

This will be a great starting point for people going through your code to figure out why the required output is not coming.

Well, if you ran what you posted, nothing will happen. You defined these functions and classes but you haven't actually done anything with them. None of these get called during the execution of the script.

This may sound dumb but do I call them?