woooee 814 Nearly a Posting Maven

But you can see there is no function in last line of code at all:
SizeDiffE(k) = j

Try a
print type(SizeDiffE)
to see what it is. Also, if SizeDiffE(k) is not passing 'k' to the function SizeDiffE() then what is it doing. If it is a tuple, then it can't be modified. If it is a list then use
SizeDiffE[k] = j
It is difficult to tell with just this snippet of the program, so post some code on what these variables do as well. Also, comment the last line to confirm that it is the error. It may be printing the error after the last line, but referring to a previous line.

woooee 814 Nearly a Posting Maven

Jeff's pseudo-code with total_replacement and misses fields added to keep track of successes vs failures

total_replacement=0
misses=0
total_guesses=0
while the_user_still_isn't_dead_yet:
   do_turn(...)            # fill in the ... with your variables
   total_guesses += 1
   display, count = new_display(...)
   if count:     ## letter was found and replaced
      total_replacement += count
      print an encouraging message
   else:    ## no letter replaced=miss
      misses += 1
      make sure the user gets one step closer to hanging
print "You guessed %d times, with %d letters replaced and %d misses" % 
       (total_guesses, total_replacements, misses)

Edit: In this version of hangman if the 'secret word' is "abac" and the guess is an "a", are both a's replaced or just one? It affects the way the function replaces.

woooee 814 Nearly a Posting Maven

It's impossible to tell if someone is serious and doesn't have a clue on where to start, in which case I would help, or if they are too lazy or want to scam someone else into doing it for them. I think I will start asking if this is homework, and/or for some pseudo-code at least so their little minds will have to start cranking on their own. This is a nice site and I want to do my part to keep it that way so I'll error on the side of "no clue where to start".

woooee 814 Nearly a Posting Maven
if guess in secret:
        ##-----  this will replace every "_" with guess.  You have to replace a specific position
        ## or use count to find the number to add to rep_count
        ## or you can use find() and add one to any position found to use as a start
        ##     parameter to find()
        ## add print statements to see what is happening
        print "before changing 'display'", display
        display = display.replace("_", guess)
        print "after changing 'display '", display

Another way to convert when guess is found (if this is any easier to understand)

new_display=""
   if guess in secret:
      index = secret.find(guess)
      for j in range(0, len(display)):
         this_char=display[j]
         if j != index:          ##   copy what is in display
            new_display += this_char
         else:                   ## replace this letter
            new_display += guess
            rep_count += 1
   else:
        new_display = display              ## nothing found=keep the same
return new_display, rep_count
woooee 814 Nearly a Posting Maven

This is an app that should be coded as a class with self.misses as a variable, but it would be too much to hope for that you have already covered classes. Anyway, modified code to account for not being able to pass misses to the function

def new_display(secret, display, guess):    
      """Displays the replacement of underscores with letters that the user has
      guessed"""
      replacement_count = 0
      index=secret.find(guess)
      display_list=[ eachltr for eachltr in display ]
      if (index > -1) and (display_list[index]=="_"):  ## not already replaced
         display_list[index]=guess
         display="".join(display_list)
         replacement_count += 1

      return display, replacement_count
##
display, replacement_count = new_display(secret, display, guess)
if replacement_count:     ## letter was found and replaced
   total_replacement += replacement_count
else:    ## no letter replaced=miss
   misses += 1

WOW, I just became a "Junior Poster in Training". Guess I'll have to visit here more often. My available time is hit and miss though.

woooee 814 Nearly a Posting Maven

set.Set has nothing named elems. Beyond that it is hard to say. Post a question to the author at ActiveState, or e-mail them directly if there is an address. Also, post some code with what it is you are trying to do so someone can come up with something that works.

woooee 814 Nearly a Posting Maven

You only have to update the "display" variable and keep track of misses as in this snippet.

def new_display(secret, display, guess, misses):    
      """Displays the replacement of underscores with letters that the user has
      guessed"""
      index=secret.find(guess)
      display_list=[ eachltr for eachltr in display ]
      if (index > -1) and (display_list[index]=="_"):  ## not already replaced
         display_list[index]=guess
         display="".join(display_list)
      else:
         misses += 1
      return display, misses

It would be simplier if "display" were declared as a list and you only worked with a list. That would avoid converting to a list and then converting back to a string.

woooee 814 Nearly a Posting Maven

How can I sort it by any columns?

There is a way to do this using a function, but you will have to at least __try__ to do it yourself first and then post the code here. I hope you understand that it is considered rude to "place your code order" and then sit back and wait for someone else to do it for you.

woooee 814 Nearly a Posting Maven

First off, Python doesn't really have arrays unless you include some of the add on packages. Python uses lists, so I would suggest that you take a look at lists. Combining is a simple matter. You can iterate through the lists with a for loop, creating a new list with the combined pairs. Itertools will also do this but that may be more than you want. Post some code and we'll let you know our opinion on how you can improve it/get it to work.

woooee 814 Nearly a Posting Maven

Look through the projects for beginner thread. This or something similiar is sure to be there.

woooee 814 Nearly a Posting Maven

Look at the line following
elif status == 0.3:
And why do you have if/elif? Why not just print the value?

woooee 814 Nearly a Posting Maven

You want to add buttons for the functions to add, multiply, etc and tie that to the proper event. Right now, every button you push calls buttonNPush which prints the button. You also have to issue a get() to retrieve data. See this link for an example.
http://www.uselesspython.com/calculator.py

woooee 814 Nearly a Posting Maven

This is such an easy problem, I suggest you really try to understand it!

Also, a Google for "fibonacci python" has everything anyone could want. These posters are too lazy to ever make it as a programmer.

woooee 814 Nearly a Posting Maven

It would be better to use an existing tool like Metakit or SQLite. This pages show how it would be done with Metakit http://www.equi4.com/metakit/python.html

woooee 814 Nearly a Posting Maven

If you want to access or print all the numbers, append them to a list
test_list = [1, 2] ## Fibs can be started with any 2 numbers
test_list.append( test_list[-1]+test_list[-2] )
print test_list

woooee 814 Nearly a Posting Maven

Try append instead of add. Any tutorial or on-line book can help you with lists and how to add/append items.

woooee 814 Nearly a Posting Maven

1 hydrogen H 1.0079

if len(parts) == 4:
   print float.parts[4]
else print 0 '%s does not have a well defined atomic weight.' % s(parts[3])

The elements in a list are numbered from 0 to length, so your list is [0]-->[3]. Since you didn't ask any questions, I have to assume that this is the problem.

if len(parts)==4:
   print float(parts[3])
else :
   print "no atomic weight for %s" % (parts[1])

## or
try:
   a_weight = float(parts[3])
except:
   print "no atomic weight for %s" % (parts[1])
woooee 814 Nearly a Posting Maven

http://www.python-eggs.org/ has links to other sites organized by type. For code examples google activestate.com and faqts.com

woooee 814 Nearly a Posting Maven

>>> a=b="test"
>>> print a
test
>>> print b
test
>>> id(a)
3084724384L
>>> id(b)
3084724384L

Or convert the string to a list and then back to a string when you are finished.

woooee 814 Nearly a Posting Maven

This is a simplification of what the data looks like (hundreds of lines like this):
[two spaces]6.0730000e+003[tab][one space]-9.2027000e+004[tab][two spaces]7.8891354e+01[tab]\r\n

string.split() treats all whites space (space, tab, newline) the same
s=" 6.0730000e+003\t -9.2027000e+004\t 7.8891354e+01\t\r\n"
print s.split()

woooee 814 Nearly a Posting Maven

I was just thinking about this myself and came up with ClientForm, but haven't tried it yet.
http://wwwsearch.sourceforge.net/ClientForm/

woooee 814 Nearly a Posting Maven

I was just thinking about this myself and came up with ClientForm, but haven't tried it yet.
http://wwwsearch.sourceforge.net/ClientForm/

woooee 814 Nearly a Posting Maven

It is easiest to write the data to a file, close it, and then call lpr using os.system() providing you want plain text. Anything more and you have to format it. Postscript is the easiest way to format output.

woooee 814 Nearly a Posting Maven

See this quote on the main page " We only give homework help to those who show effort"

woooee 814 Nearly a Posting Maven

Where is your info coming from? The link below to the Python docs specifically states that one can do microseconds. On my computer, at this time,
print now.microsecond
988561
Also, a google for "python datetime, microsecond" yields 16,800 hits (some of which are dupes) but none the less you will have to do it yourself asI have no desire or time to spoon feed everything to everyone. Saying that the datetime module will do microseconds is more than enough of a hint. Some basic research would serve you much better. Imaginary "truths" will not.
http://docs.python.org/lib/datetime-time.html

woooee 814 Nearly a Posting Maven
woooee 814 Nearly a Posting Maven

Finally, you can also use a dictionary for the menu options = def selectoption(). The dictionary may be a dictionary of lists. The option number, 1,2,3,4, etc is the key. Each key has a list = [ "menu message", "you have chosen to message", function_to_execute ]. You can execute the function in dic_list[2] for this example, like the following simplified example. Again, as with the withdrawal amounts, you only have to change or add to the dictionary to edit the menu

##  define some simple function to execute
def funct():print 12345
#
## use exec to call the function
x = 'funct()'
exec(x)
woooee 814 Nearly a Posting Maven

There is a simplier way to do the cash withdrawal as well

def withdrawal():
     withdrawal_dic = {}
     withdrawal_dic[1] = 50           ## all of these could be done on one line
     withdrawal_dic[2] = 100         ## or with a for loop and +50 each time
     withdrawal_dic[3] = 150
     withdrawal_dic[4] = 200
     max = len(withdrawal_dic)     ## assumes all of the keys (numbers) are sequential
     max_p1 = max + 1
     # now if you want to add more amounts or change one,
     # you just alter the dictionary         
     valid = 0
     while not valid :
          print "================================"
          print " Please select one of the below "
          for key in range( 1, max_p1) :
               print " %d $%d" % (key, withdrawal_dic[key])
          print "================================="
 
          amount= raw_input ("Please make your selection:")
          print "===================================="
          if (amount > 0) and (amount <= max) :
               print "You have chosen to withdraw $%d" % (withdrawal_dic[amount])
               print "\nPlease take your cash"
               print "================================="
               ##-----  NOTE: the following line should come before the break
               #Insert coding to remove cash from balance
               valid = 1
          else:
               print "Invalid Selection - Re-enter\n\n"

I haven't tested this, but you can certainly find any typos, etc, so I'll be lazy and not test it myself.

woooee 814 Nearly a Posting Maven

If I enter any pin number, the program will accept it because it is > 1000 or < 9999

#Checks if pin is within range of 1000 to 9999  
valid = 0
while not valid :
     if (pin > 999) and (pin < 10000) :
          print "Pin accepted"
          if pin== x:
               print "Valid Pin"
               valid = 1
          else :
               print "Invalid Pin"
               pin()
     else :
          print "pin must be between 1000 and 9999"
          pin()
woooee 814 Nearly a Posting Maven

It's your extra credit, not mine. You'll have to come up with some code to start with or at least some ideas.

woooee 814 Nearly a Posting Maven

Do you know about Python's built in sort? Try
print this_list.sort()
Bubble sorts are pretty straight forward btw.

woooee 814 Nearly a Posting Maven

The datetime module will do micro-seconds

import datetime 
print datetime.datetime.now()
time_now = datetime.datetime.now()
print time_now
woooee 814 Nearly a Posting Maven

Try a="itself ‘a parody’."

woooee 814 Nearly a Posting Maven

each plugin .py file is executed (via execfile()) by the PluginManager

I am not 100% sure what you are doing, but wouldn't you want the PluginManager to be an inherited class. It should also have methods to keep track of all plugins created, which "self.Plugins[newplugin.name] = newplugin" should provide, if that is your problem, and as well should be able to pass them to any other object asking for them. If you have several separate classes calling the plugin manager, then you want a wrapper program of some sort that can pass the identity of the single PluginManager instance to those classes, so they are all using the same instance. Info can also be stored on disk in a single database that any process can access, but that is likely overkill. If I understand what you are trying to do.

woooee 814 Nearly a Posting Maven

You might want to try

import string
file_pointer= open('wordlist.txt', 'U') 
dictList = file_pointer.readlines()
file_pointer.close() 
 
x = 0
newDict = ''
stop = len(dictList)
while x < stop:
##  you could also use "for each_rec in dictList :"
woooee 814 Nearly a Posting Maven

If you just want to download, you can use wget with the --user and --password options with a frontend to call it at specific times. I don't know if that will solve the problem, but it does have a resume option, so you at least won't have to start over again.

woooee 814 Nearly a Posting Maven

I like your solution, and I don't think there is any other way to handle the ace problem

but was informed by one of my students that I put in a poker-like betting system instead of the blackjack betting system

They always know more than we do. Viva la future.

woooee 814 Nearly a Posting Maven

This will print your PYTHONPATH. If the path you want is not listed, and it shouldn't be because your program isn't found, then you have to use sys.path.append to add it.

import sys
path_list= sys.path
for eachPath in path_list :
   print eachPath
woooee 814 Nearly a Posting Maven

import win32API.client
ImportError: No module named win32API.client

I use Linux, but I think you would want to import win32API, without '.client' although I'm not sure. If that fails, search for win32API on you system. It is likely that you have to append the path to PYTHONPATH using sys.path.append( some_path_name).
EDIT: Thinking that this has to have been done already, I found this link
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/483742
This routine also requires xlrd, and the author gives a download link in the comments at the top. Python is great. There are code snippets that do so many things.

woooee 814 Nearly a Posting Maven

If you want to find file date,
stats = os.stat( filename )
print time.ctime( stats[8] )
prints 'Tue Dec 26 14:28:16 2006'
string.split, etc. yields the month, although I think you should also take the year into account.

woooee 814 Nearly a Posting Maven

... one of the while loops has an eternally unfulfilled condition.

This is the only thing that could cause this problem (so of course it's something else). Add a separate counter to each while loop and exit after max cycles.

ctr_1 = 0
while True :
   ctr_1 += 1
   if ctr_1 > max_loops :
      print "ctr_1 exceeded max", ctr_1, max_loops
      break

This will at least tell you which loop has the problem. Also, this is something you may want to do when testing any while() loop.

woooee 814 Nearly a Posting Maven

originally I thought it was by ascii value, but then 11 would have been the min value since ascii 1 is lower than ascii 7.

11 is only less than 7 on the planet Bizarro, and any number AFAIK is sorted before letters so they are all first, because any digit is less than any character. Note that there is a difference between 11 (decimal 11) and '11' (decimal 49, decimal 49) and they will be sorted differently.

woooee 814 Nearly a Posting Maven

Instead of
self.hours=credits. do you want to total them
self hours += credits

woooee 814 Nearly a Posting Maven

How does Python handle mixed type lists to get such a result?

Pretty much, all pc's use ascii encoding and sort in "ascii order", see http://www.asciitable.com/

woooee 814 Nearly a Posting Maven
def main():
        grade_str = raw_input("Enter gradepoint or (Enter to quit): ")
        if grade_str == "":
            break
        try:
            grade = float(grade_str)
        except ValueError:
            print "Error, use floating point number"
            return

You want the "try :" statement as the first statement after "while 1:". That will give you an error message if a number is not entered. If an integer is entered, it can legally be type cast into a float. If a float is entered and you try to convert it into an integer you will get an error, so inserting a "grade_int = int(grade_str) and another try:/except: statement will do the trick, but it seems cumbersome. You could also use divmod(grade_float, 1) and check for a remainder. Can someone legimately have a gpa of 70? If so you want to be able to enter an integer. If the gpa is entered as 0.70, then you want to test that the float is less than one.

while 1:
     try:
        print
        grade_str = raw_input("Enter gradepoint or (Enter to quit): ")
        if grade_str == "":
            break
        grade = float(grade_str)
        try :
           grade_int = int(grade_str)
           print "Error, use floating point number"
        except :
           print grade
     except ValueError:
            print "Error, use floating point number"

Edit: Added additional try/except statement. Sorry, I did the first post in a hurry.
Edit-2: I would suggest that you have a GetInput function that you would pass "grade point" or "credit hours" to, it would get the input and convert to floating point and return the number …

woooee 814 Nearly a Posting Maven

File "C:\Python23\p2sort.py", line 40, in main
if dfield == gpa:
NameError: global name 'gpa' is not defined

I think you want "gpa" in quotes.
if dfield == "gpa":
A simple menu would be easier for the user, with 1=gpa, etc. In any case, you should have a list of correct responses, or be able to add something like 0 < number < 4, to check for a valid input.

woooee 814 Nearly a Posting Maven

Another error that happens is if the program is expecting a number and gets a letter.

if input_string.isdigit():
   do_something()
else :
   print "Enter a number"

if someone hits enter by mistake without entering anything, it errors, is there a way to avoid that?

if (input_string) and len(input_string) > 0 :
## -----or
try :
   input_str = raw_input( "Enter a Number --> " )
except :
   print "No number entered"
## -----or the old stand by
input_str = ""
while (len(input_str) < 1 )  or (not input_str.isdigit() ):
   input_str = raw_input( "Enter a Number --> " )
woooee 814 Nearly a Posting Maven

The outside functions on the far left hand side = n-1 each time around the loop
The inside function on the far L.H. side = n-2 each time around loop

If n=list element >= input number, then n-1 and n-2 = element numbers that make up the fib, or am I also confused?

woooee 814 Nearly a Posting Maven

Let's take fib(7)

fib(7) = 13 = 8 + 5 (curr/ prev)

fib(6) = 8 = 5 + 3 (curr/ prev)

fib(5) = 5 = 3 + 2 (curr/ prev )
I am realizing I need to store some things here but I'm not sure what or how, right now.
1 1 2 3 5 8 13

Perhaps append a fib sequence to a list until the value is greater than the input number? That should give you the info. If you want to use recursion, you can use it to calculate the fib list. Personally, I would use a while loop, but whatever.

woooee 814 Nearly a Posting Maven

Not sure if this is what you want to do or not, but try replacing

else:
        value = fib(n-1)+fib(n-2)
## with
   else:
        value = fib(n-1)

You might also want to use a list to store the two fib numbers, since fibs are not sequential. Again, not sure what you are trying to do.