woooee 814 Nearly a Posting Maven

Using a for loop might be easier to understand.

test_list=[1,3,5,7]
ctr = 0
stop=len(test_list)
for j in range(0, stop):
      ctr += 1
      before_add = test_list[j]
      test_list[j] += ctr     ## ctr = j+1 in this specific case
      print "element", j, "did =", before_add, "and now =", test_list[j]
print "\n", test_list
woooee 814 Nearly a Posting Maven

Try a
print str(unicode_string_var)
This is assuming that all characters in the variable can be displayed for your locale.

woooee 814 Nearly a Posting Maven

You can use a class to do that in the following way. You could also use a list or dictionary as a container for the 10 variables and pass one list/dictionary instead of 10 variables. IMHO using the class method is preferred.

class test_class:
   def __init__(self):
      self.a="dog"
      self.b="cat"
      self.c=1
      print "__init__, a, b, c =", self.a, self.b, self.c
      self.first_func()
      self.second_func("abc")
   def first_func(self):
      self.c += 1
      print "first_func, a, b, c =", self.a, self.b, self.c
   def second_func(self, d):
      self.c += 1
      print "second_func a, b, c =", self.a, self.b, self.c
      print "d =", d

if __name__ == "__main__":
   TC=test_class()
   print "\n  now calling the functions from outside the class"
   TC.first_func()
   TC.second_func("xyz")
woooee 814 Nearly a Posting Maven

As stated previously, it is difficult to tell without code tags (use the "#" in the icon list). One problem is the two lines below: one is the function definition and the other is the calling line of that function. It is unlikely that this is the problem however. It also looks like the while loop can be an infinite loop if a1 % a2 ==0, since those values are not changed, unless the return statement exits the loop. If that is the case, then when a1 % a2 != 0 there is no value returned=None.
def zufallsZahl(a1,a2):
s1 = zufallsZahl.zufallsZahl()

It should be
def zufallsZahl(a1,a2):
s1 = zufallsZahl.zufallsZahl(b,c)

or (probably this)
def zufallsZahl():
s1 = zufallsZahl.zufallsZahl()

HTH. If not post back using code tags.

woooee 814 Nearly a Posting Maven

You want to use .set() but it must be with a Tkinter control variable. Look for the paragraph that starts with "For example, you could link an Entry widget to a Label widget" and the "Entry" paragraph at this link. The New Mexico Tech Tkinter pages are well done.
http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html

woooee 814 Nearly a Posting Maven

You'll have to post the significant part of the code as well as the error message. Please use "CODE /CODE" tags ("#" in the top box). First check that you are always using intergers.

woooee 814 Nearly a Posting Maven

ctn_no has to be an integer instead of a string-note that all of the dictionary indexes are now integers and not strings so that you have to use an integer to find something in the dictionary. Also, if ctn_no can not be converted to an integer, you will get an error.
dctSequence[int(ctn_no)+1] = seq_no
or ctn_no = int(temp[16])

woooee 814 Nearly a Posting Maven

I just noticed this. After the final line of this snippet, i will always be zero if it was greater than zero, and -(2i) if it was less than zero. Is that what you are trying to do?

for i in range(0, d):
       if (i % 7 == 0)or (i == 0):
                i -= i
woooee 814 Nearly a Posting Maven

For those of us who were around before there were canned date/time libraries, Zeller's Congruence was common knowledge http://en.wikipedia.org/wiki/Zeller's_congruence but it would have to be modified by comparing the actual day of the week of 01-01-1900 and what you would have to add or subtract to get 01-01-1900 to be a Monday.

woooee 814 Nearly a Posting Maven

Have you tested the code below to see if it does what you think. I don't know myself but it is unclear at best and if you have to explain it, will you be able. The following untested code breaks it down into steps

def leap_year(self, year):
   if (year % 4 == 0) and not(year % 100 == 0)or (year % 400 == 0):
#   
##------- Breaking it down into steps  ---------------------------
   # eliminate this first
   if year % 400 == 0:     ## is leap year
      return 1
   ##   has to be divisible by 4
   if year % 4 == 0:
      # if divisible by 4 and 100 then it is not a leap year
      if (year % 100 == 0):
         return 0
      else:
         return 1
   return 0     ## not a leap year-->not divisible by 4 or 400

As for the days of the week, is the variable d the number of days from 1900? And is the first day in d --> weekday=0, and d==2 --> weekday=1, so then d==8 --> weekday=0 = start over again? If so you should be able to use divmod(d-1, 7) with the remainder being the day of the week.

woooee 814 Nearly a Posting Maven

The PC Python installation comes with Tkinter, i.e. TCL/TK, but as Duoas said, you will have to write a simple Python+Tkinter (import Tkinter) program and try it on the IPod. It's limited resources would not have a full blown Python installation, so who knows about Tkinter. It's doubtful that IPod has it. Maybe you can install it, but you may have to work with their native toolkit. Sorry, no one here knows much about it.

woooee 814 Nearly a Posting Maven

GUI's are specific to the OS. What GUIs are available for the IPod and how are you packaging your programs. I don't know what's available for IPods but if there is something like py2exe, you may be able to enbed the graphics in the executable. Also, TCL/Tk/Tkinter, GTK et all may or may not run on the IPod's OS. First you have to find out what's available and then if it can somehow be included with the program. Does IPod have a programming forum where these questions have already been answered. Also you should find out if IPods have a mini python interpreter already or if programs have to be compiled into some form of native code.

woooee 814 Nearly a Posting Maven

I almost never read a thread that starts with "Please help me". It is too vague to even bother with. This was one of the results of a google for "python ascii" . You can also use the ord() function (google for it) on each character to see if the decimal value is within the ASCII range. You will also have to google for ASCII decimal ranges if you don't know what they are. Also, please add "Solved" to the topic if this answers your question, so others won't waste their time reading a thread that has already been solved.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/163743

woooee 814 Nearly a Posting Maven

Or put them both in the same dictionary. There is only 100 or so-times 2

# small dictionary of chemical symbols
symbol_dic = {
'C': 'carbon',
'H': 'hydrogen',
'N': 'nitrogen',
'Li': 'lithium',
'Be': 'beryllium',
'B': 'boron'
}

keys_list=symbol_dic.keys()
for key in keys_list:
   symbol_dic[symbol_dic[key]]=key
Ene Uran commented: very nice idea +4
woooee 814 Nearly a Posting Maven

easygui is a better solution for a simple interface. If you want to learn how to program using GUIs, use Tkinter or one of the other toolsboxes. http://www.ferg.org/easygui/

woooee 814 Nearly a Posting Maven

The Python Cookbook is the first place to look. The following link states "- Added conversion to and from Julian Day number". I haven't tried it.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117215

woooee 814 Nearly a Posting Maven

A split on a number followed by a letter is the obvious place to start. It would be nice if all of the symbols were camel case, but I don't think you can rely on that. For the "OOH" in "C6H3Cl2COOH" (no pun intended), you can look for a match in a dictionary of symbols, but would have to allow for "He" and not stop at the "H". Just some off the top of my head thoughts.

woooee 814 Nearly a Posting Maven

With most GUI's you can pass parameters with the function call, so button 1 would use button_press("1") and button 2 would use button_press("2"). If this does not work with the graphics you are using, use a pass-through function

def button_pressed():
     ##do common stuff here
def button_one():
     print "button one pressed"
     button_pressed()

def button_two():
     print "button two pressed"
     button_pressed()
woooee 814 Nearly a Posting Maven

Try self.Destroy() The wiki has examples
http://wiki.wxpython.org/Getting_Started

woooee 814 Nearly a Posting Maven

With some additions to the data, note that it reports "1. first different line" as a difference when it is not and doesn't find "Another line that is different". Sorting text1Lines and text2Lines should solve the first problem since it seems to be comparing in file order. This may not make a difference since the file appears to be in ascending date order already. If there are lines in the 2nd file that are not in the first, then you will also have to insert a
diffList = list(diffInstance.compare(text2Lines, text1Lines)) routine. In general, when comparing we want to know how it is comparing.

#!/usr/bin/python

# find the difference between two texts
# tested with Python24   vegaseat  6/2/2005

import difflib

text1 = """The World's Shortest Books:
Human Rights Advances in China
Add some text lines that are not in either
1. first different line
2. line 2 added
3. also a third
"My Plan to Find the Real Killers" by OJ Simpson
"Strom Thurmond:  Intelligent Quotes"
America's Most Popular Lawyers
Career Opportunities for History Majors
Different Ways to Spell "Bob"
Dr. Kevorkian's Collection of Motivational Speeches
Spotted Owl Recipes by the EPA
The Engineer's Guide to Fashion
Ralph Nader's List of Pleasures
"""

text2 = """The World's Shortest Books:
Human Rights Advances in China
"My Plan to Find the Real Killers" by OJ Simpson
"Strom Thurmond:  Intelligent Quotes"
America's Most Popular Lawyers
Career Opportunities for History Majors
Different Ways to Sell "Bob"
Dr. Kevorkian's Collection of Motivational Speeches
Spotted …
woooee 814 Nearly a Posting Maven

You can use lists or 2 sets. But you would want both set1.difference(set2) and set2.difference(set1). You can set up a process to read both files like a merge sort would, but the set solution seems more pythonic. Depends on how large the files are though.

woooee 814 Nearly a Posting Maven

I have never heard of, let alone used graphics22. That being said, in general you have to declare a string variable, (which is different from a python string variable in Tkinter), and then use the graphics22 variation of "setText". Likewise, to retrieve text you would use some form of "getText". If you search whatever documentation you have for "string variable' and/or "settext" you will probably find an example that does display text. HTH

woooee 814 Nearly a Posting Maven

How can I combine 30 attributes into a tuple as you mentioned above so that I loop through thousands of people?

You don't have to use a tuple. That was just a convenient container for the example presented above. As vegaseat already stated, a little more info would be helpful. Give a few examples of input and what it should look like on output. It you take this from a file, and that from a list, etc. be sure to mention that. This should be fairly simple to do with python.

woooee 814 Nearly a Posting Maven

I still can not figure out how to get rid of punctuation

One of the earlier posts already mentioned this.

s = raw_input("Enter string to be checked: ")
s = s.lower()     ## don't use string as it is deprecated
s_ltrs_only = ""
for each_char in s:
   if (each_char >= "a") and (each_char <= "z"):   
      s_ltrs_only += each_char
print s, s_ltrs_only
woooee 814 Nearly a Posting Maven
# You can use a for loop
for line in open(fname, "r"):           ## One line at a time
     print line
#
# or a while loop
fp=open(fname, "r")
line = fp.readline()
while line:
     print line
     line = fp.readline()
fp.close()

This will work for the entire file. If you mean that you would want, say the first 100 lines, the while loop would be
while (line) and (ctr < 100):

woooee 814 Nearly a Posting Maven

You can also combine them and Python's garbage collector will then automatically close the file for you
for line in open(fname, "r"): ## One line at a time
## or
data = open(fname, "r").readlines()
for line in data:

woooee 814 Nearly a Posting Maven

I modified the earlier code for recursion. I do not like recursion and don't use it. A loop is easier to debug and understand. Unless you are specifically told that you have to use recursion, don't. Basically, the function calls itself until the length of the string is zero, or the condition is false. It then returns True or False. The print statement shows each recursion. There has to be a more elegant way to do this but I don't use recursion and haven't tested this code beyond a few simple examples.

def is_palindrome(string_in):
   if (string_in): 
      if (string_in[0] == string_in[-1]):
         result = is_palindrome(string_in[1:-1])
         print string_in, "is palindrome"
         if result:
            return True
   else:
      return True    ## no more letters
   return False

##----------------------------------------------------------
if __name__ == "__main__":
   s = raw_input("Enter palindrome string ")
   result = is_palindrome( s )
   print "The final result is", s,
   if not result:
      print "is NOT a palindrome"
   else:
      print "is a palindrome"
woooee 814 Nearly a Posting Maven

I'm not real sure either but perhaps something more on the line of (forgive the clumsiness of the code. I'm in a hurry)

def is_palindrome(string_in):
   if string_in[0] == string_in[-1]:
      return True, string_in[1:-1]
   return False, string_in

##----------------------------------------------------------
if __name__ == "__main__":
   s = raw_input("Enter palindrome string ")
   orig_s = s
   ok=1
   while s:
      result, s = is_palindrome( s )
      if not result:
         print orig_s, "is NOT a palindrome"
         s=""
         ok=0
   if ok:
      print orig_s, "is a palindrome"
woooee 814 Nearly a Posting Maven

You can also use:

if score < 60:
     grade="F"
elif score < 70:
     grade="D"
elif score < 80:
     grade="C"
elif score < 90:
     grade="B"
elif score < 101:
     grade="A"
else:
     print score, "is bogus"

but as stated earlier, it depends on what makes sense to you. i.e. what the outline is. Also, do you want to keep track of multiple scores for mulitple people. If so, that adds another dimension to the problem.

woooee 814 Nearly a Posting Maven

Here is an example using Tkinter. A Google for "graph python" will turn up all kinds of examples
http://www.daniweb.com/code/snippet583.html

woooee 814 Nearly a Posting Maven

Code something up and try it for yourself. If you get an error message then post the code here for some help.

woooee 814 Nearly a Posting Maven

You will not exit the while() loop because c is never "", you want to use
while c > 2: as 1 is a break (exits the while loop), and 2 is what executes exit()-and do you want sys.exit(0) instead to exit the program?

c=3
      while c > 2:
         c = int(raw_input(menu))
         if c ==2 :
           exit()   
         elif c ==3 :
           printScore()
         elif c == 1 :
             n=0
             print " nieuwe spel begint nu"
             a = random.randint(0,1000)
             break
         else : 
            print " verkeerde input"

but the 10,11 appear before the 6,9
like this:
10 : mathijs
11 : mathijs
13 : mathijs
6 : mathijs
8 : mathijs
9 : mathijs
and the sort+print code

A string like you are using in key list sorts left to right so the "1" in "10" is less than the 9. Convert to an int. This would not be necessary if you can use an int for the dictionary key to begin with.

def printScore():
   keylist = [int(key) for key in topscore.keys()]
   keylist.sort()
   for key in keylist:
      print " %d : %s " %(key,topscore[str(key)]
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

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

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

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

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

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

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

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

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

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.