ValuError using import function in class
Question: I'm sure there's a simple explanation for this (beyond just that I'm new to
Python), but let's say I have two file in the same directory. One is this
little script in a file named `lexicon.py` that checks user input:

    
    
    def string_checker3(action):
        try:
            check = isinstance(action, basestring) 
            if check:
                return True
            else:
                raise ValueError
        except ValueError:
            print "We need a string here!"
            return None
    
    def Chipcar_testgreeting(action):
        action_split = action.split()
        for i in action_split:
            strcheck = string_checker3(action)
            if strcheck == None:
                StartGame
            else:
                pass 
    

The other script, my main script, is called `newGame.py` and has a class like
this, within which I would like to call the `Chipcar_testgreeting(action)`
function.

    
    
    from lexicon import *
    
    class ChipCar(Scene):
    
    
    
        def enter(self):
            print "What's up mothafucka! Get in the Bran Muffin car!"
    
            action = raw_input(">  ")
            user_test = lexicon.Chipcar_testgreeting(action)
            user_test
    
            if(action == "shut up chip" or action == "oh no, it's chip"):
                print "forget you!"
                print action
                return next_scene('Your_death')
                #return 'Death' 
            elif(action == "hi chip" or action == "hello chip"):
                print "What's up?!?! Let's go to O&A..."
                return next_scene('Chip_in_studio')
            else:
                print "what's wrong with ya are ya stupid or sumptin? Let's go to my mudda's house, I think Lamar's there..."
                return next_scene('Chip_mom_house')
    
    FirstScene = ChipCar()
    StartGame = FirstScene.enter()
    

However, I get this error now:

    
    
    user_test = lexicon.Chipcar_testgreeting(action)
    NameError: global name 'lexicon' is not defined
    

What am I doing wrong?


Answer: As you wrote `from lexicon import *`, all the importable names from that
module are available to you directly (in other words, you don't need
`lexicon.` anymore).

If you write `import lexicon`, now you have only imported the `lexicon` name
into your module, and you need to use it and the scope-resolution operator
(that's the `.`) to get to the other names of objects inside that module. In
this case, you can use `lexicon.Chipcar_testgreeting(action)`.

So, either replace `from lexicon import *` with `import lexicon`, or change
`lexicon.Chipcar_testgreeting(action)` to `Chipchar_testgreeting(action)`.

**The recommended option is to use`import lexicon`**.

* * *

Once you sort that out, you need to resolve another major issue which is this:

    
    
    if strcheck == None:
        StartGame
    else:
        pass
    

Not sure what do you expect `StartGame` to do here, since there is nothing
with this name in the `lexicon.py` module.

