woooee 814 Nearly a Posting Maven

l = abs(math.sqrt(2)(r*r)-(y*y))
Break this formula down into one calc per line and see where the error occurs, then print the variable and it's type(variable_name), and that should tell you where you went wrong. Also, it is not polite to use "i", "l",. or "o" as single letter variable names. They look like numbers and can be confusing to someone trying to decipher someone else's code.

woooee 814 Nearly a Posting Maven

I've modified you code by adding a function to do the "HTH" and "HTT" search. Since it is basically the same for 'H' and "T', one function can do it instead of two blocks of the same code . Note that the if heads/tails > 0 appears to be worthless, since you add one to the variable on the previous line. There is one "thought group" per function. One function to flip the coin, etc., and one function to test for the string to end it.

import random
import time

def find_it(text):
   htt = "HTT"
   hth = "HTH"
   time.sleep(.1)
   if hth in text:
      print "found HTH first", text
      return True
   elif htt in text:
      print "found HTT first", text
      return True

   ##  neither found
   return False
 
def htthth(N):
    
    heads = 0
    tails = 0
    flips = 0
    text = ""
    hthCount = 0
    httCount = 0
    found = 0

    while (flips < N):
        print flips
        flips += 1
        flip = random.randint(1,2)
        if flip == 1:
            heads += 1
##            heads will always be > 0 since you 
##            just added one to it
##            if heads > 0:
            
            text += 'H'
            found = find_it(text)
            if found:
               hthCount = 1
               flips = N
        else:
            tails += 1
            text += 'T'
            found = find_it(text)
            if found:
               httCount = 1
               flips = N
            
htthth(10)
woooee 814 Nearly a Posting Maven

Once the user gives the program these parameters I would like to put it into the file below on line 11 and re save it as Compare # 2.asc.

Apparently he does want to change the file posted, but since every tutorial covers file read/write, and no effort has been made by the OP to produce any code, -1 to the "write the program for me" posts.

woooee 814 Nearly a Posting Maven

Hey I did this in class the other week. This code is simple and works perfectly

import random
Num = int(raw_input("enter number of coin flips:"))

coinf = 0
h = 0
t = 0

while coinf < Num:
    coinf = coinf + 1
    rand = random.randint(0,2)
    if rand == 1:
        h = h + 1
    else:
        t = t + 1
print h, "heads",t, "tails"

What kind of a grade did you get. Hopefully your teacher did not give a passing one. Run this modified version and see if you can tell why you will always get approximately twice as many tails as heads.

import random
Num = int(raw_input("enter number of coin flips:"))

flips_dic = {}
coinf = 0
h = 0
t = 0

while coinf < Num:
    coinf = coinf + 1
    rand = random.randint(0,2)
    if rand not in flips_dic:
       flips_dic[rand] = 0
    flips_dic[rand] += 1
    if rand == 1:
        h = h + 1
    else:
        t = t + 1
print h, "heads",t, "tails"
print flips_dic
woooee 814 Nearly a Posting Maven

I don't remember if SQLite is installed by default or not. A test is of course
import sqlite3
Even though you may not use it, there are various apps that do. Also, check out the programming forum there http://ubuntuforums.org/forumdisplay.php?f=39

woooee 814 Nearly a Posting Maven

I just skimmed your code, but it looks like a set() will do some of this for you. Using a builtin is easier and more reliable as it has been tested thousands of times. And cudos for figuring out the logic.

user_input = ["three", "four", "five", "six", "seven", "eight", "nine", "ten","one", "two"]
user_input1 = set(user_input)
list1 = set(["one", "two", "three", "four", "five", "six", "seven", "dog","horse"])

set_3 = list1.intersection(user_input1)
print "common to both", set_3
print "in user_input only", user_input1.difference(list1)
#
#Also, a dictionary would probably work better here
#
list1 = [["1",["one"]],
         ["2",["two", "one"]]]   ## snipped for testing
dic_1 = {"1":["one"],
         "2":["two", "one"] }
print "\n", dic_1["2"]
print dic_1["2"][1]
woooee 814 Nearly a Posting Maven

# changes the system's current dir. path to specified path

It doesn't change the path, it adds that path to the list that Python searches. You can print sys.path if you want to see what it is.
sys.path.append("/engine/lib/") ## or whatever it is
import sprite_class
and then
sprite_obj = sprite_class.Sprite()
to call a function in the class Sprite, use
sprite_obj.function_name(vars)
to access a variable
print sprite_obj.starting_y
Note that the function CD does not return anything so sprite_obj will be destroyed when you exit the function.

woooee 814 Nearly a Posting Maven

You should not be using "is" for comparison. It is used to test if the objects are the same. Guido, et al decided to store an internal list of 1-256 and reference the list for those numbers, so if you try:
x=257
print x is 257
it will print False because they are different objects.

#if n is not 0:
        ## use
        if n:     ## if n != 0: will also work

            #if a % n is 0:
            if a %n != 0:
woooee 814 Nearly a Posting Maven

You will have to link them some way. You can combine them and sort as below, otherwise you will have to associate "yes" with zero, "i don't know" with one, etc. and reorder the list named results after sorting the labels list, but there isn't any reason why you have to have two separate lists instead one list of lists. You could also use a dictionary of lists, using each element in labels as the key, pointing to a list that contains one or more results, and then sort the keys in what ever order you want.

labels=['yes',"i don't know",'no']
results=[5,60,30]
list_3 = zip(labels, results)
list_3.sort()
print list_3
woooee 814 Nearly a Posting Maven

You can also use divmod.

cnum = 21
cntnu = 1
currint = 1
  
#Begin Loop
 
while cntnu == 1:
	currint = currint + 1
	whole, remain = divmod(cnum, currint)
	if 0 == remain:
		cntnu = 0
		print "Factorization Found."
		print whole, remain 
		print currint, cnum
	else:
		print currint, "Factorization failed. Trying next factorization..."
woooee 814 Nearly a Posting Maven

You don't have to compile Python programs. It is interpreted/byte compiled, which basically means that it takes care of that. If you are just starting, I would suggest that you use Idle (comes with Python) until you are more comfortable with the language. A somewhat dated link http://www.ai.uga.edu/mc/idle/index.html

woooee 814 Nearly a Posting Maven

If you just want to convert text, there are tools like txt2pdf. You'll have to Google "text pdf" to see what runs on your OS.

woooee 814 Nearly a Posting Maven

Of course, I could do simple list comparison.

However you organize it, you will have to compare all fields, i.e. cow_list[1] == sheep_list[1] = number of legs ==> ctr += 1 A hashed db or MySQL would only improve things if you were looking for all animals with 4 legs as you could look that up. It would not tell how similar 2 animals were. You would still have to compare individual attributes.

woooee 814 Nearly a Posting Maven

It is easiest to use the print spooler "lpr" (on Linux but Mac is BSD based so there should be something similiar), otherwise you have to make sure that the data you want printed is formated properly for your particular printer, i.e. standard text, or a postscript or PDF file. Since your native language does not appear to be English, I am not sure what UTF characters are considered "standard text" in which languages and which printers, so using the print spooler converts where necessary to something the printer recognizes. To do this, you save whatever you want to a file, close the file and then use subprocess or os.system to call lpr + the file name. You can access/write to the printer driver directly. If you do not already know how to do that, then you don't want to try as you could easily overwrite the device file and then have to reboot before you can use the printer. Idle has a print to printer menu item and you could look at that code also. And a MAC OS-X forum would be the place to ask about lpr/print spoolers.

woooee 814 Nearly a Posting Maven

Can the edit wizard be altered to allow more than 4 packs to be used?

And you will have to post your "edit wizard" code in order to get advice on how to change the program.

woooee 814 Nearly a Posting Maven

I need the window to just refresh each time.

I think you want root.update(). This is a simple example that I had lying around (click the start button to test).

from Tkinter import *
import time

## ---------------------------------------------------------
##   Demonstration of window update from FAQTs
## ---------------------------------------------------------
class TestUpdate:
   def __init__(self, top):
      self.top=top
      self.test_list = Listbox(top)
      self.test_list.pack(fill='both', expand=1)

      self.test_b = Button(top, text='Start', command=self.loop)
      self.test_b.pack(fill='x', expand=1)

      self.exit = Button(top, text='EXIT',
          command=top.quit, bg='red', fg='white' )
      self.exit.pack(fill=X, expand=1)

   def loop(self):
      for x in range(5):
         print x+1
         self.test_list.insert('end', 'Foo %d' % x)
         self.top.update()
         time.sleep(1)

root = Tk()
T=TestUpdate(root)
root.mainloop()

Also, consider using a class structure for this. The local and global variables are going to kill you trying to figure which is what, where.

woooee 814 Nearly a Posting Maven

take printout for the output of that program

Do you mean save it in a file, send to the printer???

don't judge me because I'm a year 8!

My new sig: "Don't judge me because I'm a dumb-ass".

woooee 814 Nearly a Posting Maven

We should answer questions in such a way that
1. The OP learns something
2. Don't provide the entire program. Just solve the specific problem.

In this case, the OP hopefully learned the value of using the class structure. The problem was likely related to the use of local and global variables, although I'm not going to spend time figuring that out. Also, I doubt that someone taking CS380 would write a program like that. They would still be taking CS102, which means this may be someone learning on their own. Anyway, it does seem that the OP bit off more than they could chew and is not continuing with it, and probably has gone back to the online tutorials. Which is the lesson here.

woooee 814 Nearly a Posting Maven

Python (with batteries included) usually has a tested tool that will already do most common things. In this case, you want sets.

list1 = ['spam', 'eggs', 'bacon']
list2 = ['spam', 'ham', 'king richard']

set_1 = set(list1)
set_2 = set(list2)

##matchitems(list1, list2)
new_set=set_1.intersection(set_2)
print new_set
## works either way
print set_2.intersection(set_1)
#
## FYI
new_set = set_1.difference(set_2)
print new_set
woooee 814 Nearly a Posting Maven

Is this working now, or have you given up?

woooee 814 Nearly a Posting Maven

Q: Is it true that a former president wanted to close the patent office, claiming everything had already been invented?

A: Although we find the statement patently absurd, it sure does pop up everywhere. But it appears to be yet another legend.

The story that's most often told is that in 1899 the head of the U.S. Patent Office sent his resignation to President McKinley urging the closing of the office because "everything that could be invented has been invented." It's been told and retold so often that even President Reagan used it in a speech.

The "quote" is often attributed to Charles H. Duell, who was Commissioner of Patents in 1899. However, according to The Great Idea Finder, Duell was far from pessimistic about the future of new inventions and patents. He even encouraged Congress to improve the patent system.

My Comment: This page http://www.uspto.gov/go/taf/issuyear.htm says that in 1899, 24,000+ patents were issued. Hardly indicating that everything had been invented.

woooee 814 Nearly a Posting Maven

How come? I mean did he just wake up one morning, rub the sleep from his eyes, and go "Huh?! What's this then??"

Early in his career, he flipped off a Klingon.

woooee 814 Nearly a Posting Maven

effbot has some nice ultra noob stuff for the beginner. See here (and you might want to check out the rest of their tutorial and then continue on with whatever on you have now) http://effbot.org/pyfaq/how-do-i-run-a-python-program-under-windows.htm

Edit: I just realized that this tutorial is for version 2.5 and lower, so it may throw some curves for someone who isn't familiar with the differences. You probably want to stick with the 3.0 tutorial that you have. Also, if you use Idle, which should have been installed along with Python, you can save and run the program from Idle, and it makes learning a lot easier IMHO. It should be under the Start-->Programs-->Python menu (or something similiar). A slightly old tutorial for Idle http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html

woooee 814 Nearly a Posting Maven

Part of the problem may be all of the global variables, and the functions possibly using locals instead of globals. This program should be using a class anyway. Here it is, converted to a class. The final line prints
Final print [[0, 0], [0, 1], [0, 2], [0, 3]]
Don't know if that is what you were expecting or not. And if you don't already know this, you can pipe any printed output to a file if there is too much to fit on the screen, with the ">" operator. From the command line, this will pipe any output to a file named "test1.txt".
./program_name > test1.txt

#!/usr/bin/python

#Scott Landau
#CS 380
#Assignment 1 Programming Portion in Python
#Created - 4/6/09
#Last Edited - 4/8/09
 
import pdb
 
class Queens:
   def __init__(self):
      self.testing = True     ## print diagnostics
      
      #n is going to be equal to 4 for this queens problem.
      self.n = 4
 
      #Assigning the empty list to initialState.
      self.initialState = []
 
      #Making an allDirections list.
      self.allDirections = [[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]]
 
      #declare the list 'state' which represents the number of non threatening
      #queens that have been placed on the board.
      self.state = []
      
      #defining allRules list which the contents of which will be created 
      #in makeRules
      ##self.allRules = []     ## declared in makeRules()
 

   def goal(self):
        if self.testing:
	   print "goal()", len(self.state), self.n
	
	if ((len(self.state)) == self.n):
		return True
	else:
		return False
 
   #defining all the rules for an nxn board. assigning these rules to allRules
   def makeRules(self):
	 self.allRules = []
	 for
woooee 814 Nearly a Posting Maven

Use one dictionary of lists for everything. Simplified for easier understanding =

KEYWORDS_dic = {}
KEYWORDS_dic['test'] = []
KEYWORDS_dic['text'] = []
word = orig_word.lower()
if word in KEYWORDS_dic:
   KEYWORDS_dic[word].append(number)
woooee 814 Nearly a Posting Maven

Something like this, using an interim list (untested). You could also put this in a function and return the word and counter the first time it is found.

logfile = open("logfile.txt", "r").readlines()
KEYWORDS = ['test', 'text']
counterline = []
counter = 0
for line in logfile:
    junk_list = []
    for word in line.split():
        counter+=1
        if word in KEYWORDS:
            junk_list.append(counter)
            print word
        if len(junk_list):
           counterline.append(word + ":" +junk_list)
print KEYWORDS
for rec in counterline:
   print rec

To get exactly what you want, you would have to reverse your logic and use
for word in KEYWORDS:
that is, find all occurences of each KEYWORD. Now, you will have one entry if the first word is found, and another entry if the fifth word equals the first word, when you get to the fifth word. Hope that makes sense.

But since you mentioned a dictionary, use a dictionary of lists if the word is found, instead of the two lists. Try it yourself, and post back if you can't get it.

woooee 814 Nearly a Posting Maven

You can replace this:

#precondition to the actions checker
def precondition(rule,state):
	if not blocked(rule,state,(allDirections[0])):
		if not blocked(rule,state,(allDirections[1])):
			if not blocked(rule,state,(allDirections[2])):
				if not blocked(rule,state,(allDirections[3])):
					if not blocked(rule,state,(allDirections[4])):
						if not blocked(rule,state,(allDirections[5])):
							if not blocked(rule,state,(allDirections[6])):
								if not blocked(rule,state,(allDirections[7])):
									return True
	else:
		return False
##---------------------------------------------------------
##   with  (not tested)
##   in other words, if any one is blocked, return false
##   This is the way the code appears to work.
##---------------------------------------------------------
def precondition(rule,state):
   for j in range(0, 8):
      if blocked(rule,state,(allDirections[j])):
         return False
   return True

Whe you have the same line of code multiple times, consider a for() loop or a function instead.

A print statement here shows that len(state) remains at zero.

def goal(state):
        print len(state), n
	if ((len(state)) == n):
		return True
	else:
		return False

Also, put in a counter while testing to eliminate endless loops.

ctr = 0
ctr_max = 100
while (not goal(state)) and (ctr < ctr_max):
        ctr += 1
        if ctr == ctr_max:
           print "Bye, Bye.  ctr_max limit reached."
	for l in range(0, (len(allRules)), 1):
		if precondition((allRules[l]),state):
			applyRule((allRules[l]),state)
			print state
 
print state
woooee 814 Nearly a Posting Maven

If you want to print from the word to the end of the line, use index. This untested code will tell you if a word is found. You can then use .join to print out what you want.

for line in logfile:
    words_list = line.split():
    for word in KEYWORDS:
          ## or for word in words_list:
          ## use the shortest list in the for() statement
          print word
          if word in words_list:
               el_number = words_list.index( word )
               print "found", el_number, word
    print line
    #Move to next line
sneekula commented: good idea +6
woooee 814 Nearly a Posting Maven

I think the problem is this line, if I understand you correctly.
self.entryb["variable"] = self.bringout
I think you can only use "StringVar()" and "textvariable=" with a button since there is no data entry or changing of the text, so change the code to something like

self.bringout = StringVar()
        self.bringout.set("0" )
        self.entryb = Button(parent, text="Accept", 
                             textvariable=self.bringout,
                             padx="1m", pady="1m")
        self.entryb.pack()

and then convert to an int, if that is what you want, after the ".get". You can use IntVar for an entry box, radio button, scale, etc.

woooee 814 Nearly a Posting Maven

2. In order to get to condition 2,the values of "x", "y", and "z" must all be the same.

Double check this. With my limited tests, it appears that if x == y, it doesn't matter what z is (or y == z and the value of x doesn't matter), which would mean that condition 3 would start with x != y to get by condition 2, and then additional constraints to get by condition 1. I doubt that there is only one set of numbers (which is what you have) to get to condition 3.

woooee 814 Nearly a Posting Maven

You might start with code tags (use the "#" icon) and then explain what the program you posted does, as it doesn't appear to make sense. Once you reach this line
while R[0]<R[1]:
it appears to be an infinite loop, but it's difficult to tell without proper indents.

Basically, you want
1) the dictionary that you have named "d" and
2) test that all input letters are in the dictionary, with a test:
3) if the value of this letter is less than the value of the next letter then subtract the value. Otherwise, add the value. Post some code with comments as to what it does if you want more help.

woooee 814 Nearly a Posting Maven

For your example, the position is found, i.e. True is returned. Consider using "in" when comparing the two lists as that is the preferred method. The following illustrates this.

a = [ [0,1], [0,2], [1,2] ]
b = [0, 2,]
c = [2, 0]

if b in a:
   print "b found"
else:
   print "b not found"

if c in a:
   print "c found"
else:
   print "c not found"

What output were you expecting from the program?. The program does not print "true" because you return, or exit the function on the line before the print statement (Doh). This modified program shows that the position is indeed found.

#n is going to be equal to 4 for this queens problem.
n = 4
 
#Assigning the empty list to initialState.
initialState = []
 
#Making an allDirections list.
allDirections = [[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]]
 
#declare the list 'state' which represents the number of non threatening
#queens that have been placed on the board.
state = []
 
def goal(state):
	if (len(state) == n):
		return True
	else:
		return False
 
#defining allRules list which the contents of which will be created in next function.
allRules = []
#defining all the rules for an nxn board. assigning these rules to allRules
def makeRules(n):
	for i in range(1, (n+1), 1):
		for j in range(1, (n+1), 1):
			allRules.append([i,j])
	return
 
#making a rule list. this list will probably be refined in future assignments but it will contain the one rule that is applicable in the current state. for #now we will …
woooee 814 Nearly a Posting Maven

To start with, what do these mean and what is the order of their evaluation? Post your answer here if you want some help.

if (y>x and y<z)or(y<x and y>z):
   elif not(x!=y and y!=z):

Since you have code, you can answer the first question by brute force. Set x and y to 10, and then loop through increasing values of z to see where you get a response from the third condition. __And Then Figure Out Why.__ After that you should be able to answer question 2.

Edit: Note that an "and" is two if() statements, and an "or" is an if() + elif(). So if it is easier to understand you can rewrite it.

if (y>x and y<z)
## becomes
if y > x:
   if y < z:
      print("You have entered Condition 1 because y > x AND y < Z")
##--- now for the "or"
elif y < x:    ## etc
woooee 814 Nearly a Posting Maven

A "print 'true'" statement isn't any good for debugging. It doesn't tell you anything and you don't know which function it came from. If you add the print statement to the while() loop it tells you that state[] gets very large, very quickly. That taken along with vegaseat's point takes you to

def goal(state):
        print "def goal", n, len(state)
	if ((len(state)) == n):
##		print "true"
		return True

The print statement here makes it obvious that len(state) is never equal to n. How to solve it is up to you. As a general rule though, you never want to use "equals" in a conditional, but "<" or ">" as that is only a single test and will catch an increment that jumps by more than one. While "<=" or ">=" can also be used, it is two tests per loop instead of one. HTH.

woooee 814 Nearly a Posting Maven

Test each function individually by inserting print statements. Comment everything you don't want by using triple quotes """. Since you only have one while() loop, start here.

while not goal(state):
        print "=====>while not goal(state) ", goal(state), state
	for l in range(0, (len(allRules)), 1):
		if precondition((allRules[l]),state):
			applyRule((allRules[l]),state)
		else:
			print "Rule cannot be applied, trying next rule in list."
woooee 814 Nearly a Posting Maven

A nice explaination of subprocess, which every programmer will use at one time or another, for future reference. http://blog.doughellmann.com/2007/07/pymotw-subprocess.html

woooee 814 Nearly a Posting Maven

When someone enters pay rate or hours, what happens if they accidentally enter a letter or a float instead (pay rate is $9.99)? Or does the problem let you assume that only integers are entered,

pRate=raw_input("What is their hourly rate? ")
intRate=int(pRate)
woooee 814 Nearly a Posting Maven

Upon initial inspection I see that you're opening PAY.txt as salariesWage and then employeeWage but then trying to read/write as salariesList and employeeList respectively. That should fix your reading/writing problem...

Also, that block of code should go under the while loop as well in order to write each employee. Hopefully, the reason for this is obvious. So you will have a while loop, it will do everything until "Done" is entered, which will trigger a break() statement, and then you can print something like "Bye bye" if you want to show that you have exited the loop.

woooee 814 Nearly a Posting Maven

Please put your code between code tags (the "#" icon) as no one will be able to run your program without proper indents. Generally, you use a control variable, in your case a string control variable, and the ".set " and ".get" methods to change the text or get the text. Here is a link to New Mexico Tech's page http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html From that site "For example, you could link an Entry widget to a Label widget so that when the user changes the text in the entry and presses the Enter key, the label is automatically updated to show that same text." This is their example, using different widgets than you, but the idea is the same

self.spamVar = StringVar()
self.spamCB  = Checkbutton ( self, text="Spam?",
        variable=self.spamVar, onvalue="yes", offvalue="no" )

Note the "variable=" which defines the variable that contains the text/data. Write a simple example with one widget and update the text every time you click a button. Then, you should be able to do the rest.

vegaseat commented: good ref +11
woooee 814 Nearly a Posting Maven

I can loop through all three questions ONE time and that's it.

while hours<1 or hours>60:
            hours=int(raw_input("Enter the number of hours

If you entered 42 hours on the first pass, then hours still equals 42 and you will not enter the while loop. See Shibby's snippet. Use one infinite while() loop, to get all of the data, and break out of the loop when "Done" is entered.

woooee 814 Nearly a Posting Maven

Based on the statement
age = int(input('How old are you today? '))
and the print() statements, we are assuming that the OP is probably using 3.0, which doesn't have a raw_input. But someone should have asked before now. We'll have to get used to asking for the Python version number.

woooee 814 Nearly a Posting Maven

Nope. Not a standard module until 2.6. I did remember that there is a way to do it with threads using queues and a variable assigned to the while loop that can be set to False. But I don't know what it is. A google should find it though.

woooee 814 Nearly a Posting Maven

Not tested but should be close. In these types of programs, you want to set a variable to assume that there are errors and unset it only when all conditions are met.

errors = True
while errors:
   age = input('How old are you today? ')
   try:
      age_int = int(age)
      if (age_int > 0) and (age_int < 200):
         errors = False
         print('\nIn 10 years you will be %d years old.' % (age_int+10))
      else:
         print('\nThat is not a valid age! \n')
   except:
      print('\nThat is not a valid age! \n')
woooee 814 Nearly a Posting Maven

I have a symlink from /usr/bin/python to python2.5 as the default. If I want to use 2.6 or 3.x I simply use the shebang
#!/usr/bin/python3.0
They install into different library directories, so multiple versions isn't problem.

woooee 814 Nearly a Posting Maven

I use pyprocessing for this. For Python 2.5 it is pyprocessing, for 2.6 and above it is included in the distro and named multiprocessing. http://pyprocessing.berlios.de/ This will exit when you hit <Enter>.

import subprocess
from processing import Process

class test():

   def funct_1(self, name):
      subprocess.Popen("ping www.google.com", shell=True)
    
if __name__ == '__main__':
      CT=test()
      p = Process(target=CT.funct_1, args=('P',))
      p.start()

      key = raw_input("Press <Enter> to exit (or is it <exit> to enter?)")
      p.terminate()
woooee 814 Nearly a Posting Maven

Tkinter is just a wrapper around TCL/Tk, which is also a scripting language, so it defines it's own variables. So
self.t_name = StringVar()
declares the variable self.t_name as a TCL/Tk string
text = Entry(frame_e, textvariable=self.t_name, bg="white")
says that name of the variable containing the text/data, for the widget named text, is "self.t_name".
self.name = self.t_name.get()
converts a Tk string variable to a python string variable.
Here are links that between them answer pretty much any question that a normal user might have.
## Control Variables at N.M. Tech
http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html

## Fredrik Lundh's page (effbot.org)
http://www.pythonware.com/library/tkinter/introduction/index.htm

## New Mexico Tech
http://infohost.nmt.edu/tcc/help/pubs/tkinter/

woooee 814 Nearly a Posting Maven

Yes, but we're not telling you what it is.

woooee 814 Nearly a Posting Maven

You want to use a class. The variable will be visible and accessible as long as the class exists.

from Tkinter import *

class Demo:
   def __init__(self, top):
      self.name=""
      frame_e = Frame(top)
      frame_e.pack()
      self.t_name = StringVar()

      text = Entry(frame_e, textvariable=self.t_name, bg="white")
      text.pack()
      text.focus_force()

      nameButton = Button(frame_e, text="Accept", command=self.Naming)
      nameButton.pack(side=BOTTOM, anchor=S)


   def Naming(self):
      self.name = self.t_name.get()
      print self.name
      root.destroy()

root = Tk()
root.geometry=("100x100+100+50")

D=Demo(root)

root.mainloop()

print "name retrieved was", D.name
woooee 814 Nearly a Posting Maven

This "is" operator is meant to be used to test for the same object, not equality. Try this on your computer
a=257
print a is 257
<prints "False">
So it can give you unexpected results. You want to use:

a = True
    while a :
        a = False   ## (to exit)
##
##--- or
    a ="True"
    while a == "True":
woooee 814 Nearly a Posting Maven

This line doesn't make any sense.

x = "a" or "b" or "c" or "d" or "e" or "f" or "g" or "h" or "i" or "j" or "k" or "l" or "m" or "o" or "n" or "q" or "r" or "s" or "t" or "u" or "v" or "w" or "x" or "y" or "z" or "A" or "B" or "C" or "D" or "E" or "F" or "G" or "H" or "I" or "J" or "K" or "L" or "M" or "O" or "P" or "Q" or "R" or "S" or "T" or "U" or "V" or "W" or "X" or "Y" or "Z"

For ruture reference, if you want to stick with your original idea, do not use "is 'a'"; it would be

x = raw_input("Enter a keyboard character: ")
if x in ["a", "b", "c", ...etc]

But as already posted, Python does most of this for you.