bumsfeld 413 Nearly a Posting Virtuoso

Try self.SetSizerAndFit(sizer)

bumsfeld 413 Nearly a Posting Virtuoso

So, what good anti-virus programs are out for Windows 7?

bumsfeld 413 Nearly a Posting Virtuoso

Should be at least 1 kilometer in diameter before it's worth one Hollywood movie!

bumsfeld 413 Nearly a Posting Virtuoso

Peanut butter M&M's. These are the best variety of M&M's in my opinion.

I agree!

Alaska pollock with zucchini and wild rice. Will have M&Ms for dessert.

bumsfeld 413 Nearly a Posting Virtuoso

You know you are complete computer geek when you like Google's new language Go.

bumsfeld 413 Nearly a Posting Virtuoso

It is better to die for something than to live for nothing.
-- George S. Patton (US Army)

bumsfeld 413 Nearly a Posting Virtuoso

Are you usng Python2 or Python3?
Are your positive numbers integers or floats?

bumsfeld 413 Nearly a Posting Virtuoso

Why so complicated?
Using a similar english dictionary file:

# mydict.txt has one English word per line
# about 74500 in total
mydict  = open("mydict.txt", "r").readlines()

print(mydict[:10])

"""my display of some words in mydict -->
['aardvark\n', 'aardvarks\n', 'aaron\n', 'abaci\n', ... ]
"""

# strip the trailing newline char
mydict = [w.rstrip() for w in mydict]

print(mydict[:10])

"""my display -->
['aardvark', 'aardvarks', 'aaron', 'abaci', ... ]
"""

# test one word
word = 'aaron'

if word in mydict:
    print("word found")  # word found
bumsfeld 413 Nearly a Posting Virtuoso

The reason you want to make something private to the class is to keep it from easily spilling out into external code. So pseudo-private will do one good job. Remember it's called private, not secret!

bumsfeld 413 Nearly a Posting Virtuoso
import os
# works on windows nt (also xp and vista) or linux
os.system(['clear','cls'][os.name == 'nt'])

If [os.name == 'nt'] is True then this becomes effectively 1. So it picks item at index 1 from the list which is the Windows command 'cls'. If it's False, it becomes 0 and the item at index 0 (zero) is used, which is the Linux command 'clear'.

bumsfeld 413 Nearly a Posting Virtuoso

Read vegaseat's comment:

Lines 124 to 140 have lost their indentations as a code block. They belong to function computer_move().

You need to move all those lines to the right by 4 spaces.

bumsfeld 413 Nearly a Posting Virtuoso

You may not want to add letters to the list that have zero count.

bumsfeld 413 Nearly a Posting Virtuoso

Also with Python3 you don't have to use
fahrenheit = (9.0 / 5.0) * celsius + 32
you can just use
fahrenheit = (9 / 5) * celsius + 32
since '/' is now floating point division and '//' is integer division.

bumsfeld 413 Nearly a Posting Virtuoso

If you are curious, also check this out:
http://www.daniweb.com/code/snippet216539.html

bumsfeld 413 Nearly a Posting Virtuoso

Did you download the code or retype it manually yourself?
There are some errors due to indentations and typos.

The return outside function error is really indentation error!

bumsfeld 413 Nearly a Posting Virtuoso

Seems to me that you also have to consider the time that re.compile() needs.

bumsfeld 413 Nearly a Posting Virtuoso

Some corrections:

num = 0
mylist = []

while num < 10:
    num = num + 1
    mylist.append(num)

print(mylist)

for item in mylist:
    print(item)
bumsfeld 413 Nearly a Posting Virtuoso

Okay that was quit stupid :f

Asking questions is never stupid! :)

bumsfeld 413 Nearly a Posting Virtuoso

This will also trap number exceeding the index:

import string

def numtolet(num):
    if num > 25: return
    return string.ascii_uppercase[num]

print( numtolet(0) )   # A
print( numtolet(5) )   # F
print( numtolet(25) )  # Z
print( numtolet(26) )  # None
bumsfeld 413 Nearly a Posting Virtuoso
# staticmethod() and classmethod()
# make it easier to call one class method

class ClassA(object):
    def test(this):
        print this
    test = staticmethod(test)

ClassA.test(4)  # 4

class ClassB(object):
    @classmethod
    def test(self, this):
        print this

ClassB.test(4)  # 4

See:
http://www.techexperiment.com/2008/08/21/creating-static-methods-in-python/

bumsfeld 413 Nearly a Posting Virtuoso

One of the solutions is pretty straight forward, with easy logic:

list1 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
list2 = [1,2,3,4,11]

list3 = []
# q1 is each sublist in list1
for q1 in list1:
    # q2 is each item in list2
    for q2 in list2:
        # do not append if sublist is already in list3
        if q2 in q1 and q1 not in list3:
            list3.append(q1)

print(list3)

"""my output -->
[[1, 2, 3], [4, 5, 6], [10, 11, 12]]
"""

There may be better solutions.
Sorry, woooee already had this solution!!

bumsfeld 413 Nearly a Posting Virtuoso

Apple Pie + Apple Cider.

Can Halloween be far away?
I like apple dumplings and fritters! Apple cider only if it's hard cider.

bumsfeld 413 Nearly a Posting Virtuoso

As performance is concerned, the file read from disk will be the slowest part by far!

bumsfeld 413 Nearly a Posting Virtuoso

Do you mean highest frequency first?

Simply add this to the end of the code:

print '-'*30

print "sorted by highest frequency first:"
# create list of (val, key) tuple pairs
freq_list2 = [(val, key) for key, val in freq_dic.items()]
# sort by val or frequency
freq_list2.sort(reverse=True)
# display result
for freq, word in freq_list2:
    print word, freq
bumsfeld 413 Nearly a Posting Virtuoso

I need to prompt a user to type in a text file name and then take that file and and count the amount of words in the file. I have this code which counts the words in a file(that may not be "perfectly" written). I cannot figure out how to take the prompt text file and and get those words counted. I add a first line of say text = raw_input("enter a text file name: ") but I cannot take the file name given and have the words counted.

text = open("rainfall.txt", "r")
for t in text:
    words = t.split()
    wordCount = len(words)
    print wordCount

text.close()

You are close:

fname = raw_input("enter a text file name: ")

fread = open(fname, "r")
# read the whole file into one string
text = fread.read()
fread.close()

# split the whole text string into words at "white-spaces"
word_list = text.split()
word_count = len(word_list)
print word_count
bumsfeld 413 Nearly a Posting Virtuoso

how to save in the memory of the phone with rms + python

Vary bad manners to hijack this thread for such question.

Start your own thread and give more info!

bumsfeld 413 Nearly a Posting Virtuoso

please help me to develop a program in C for the given problems?
1. Read the string and print the first letters of word?
2. Read the array elements and find the greater and smallest after sorting it?
3. Read the string and print the digits and vowels ?

You are in the wrong forum. Many of us went away from low level C to high level Python to solve such problems easily.

bumsfeld 413 Nearly a Posting Virtuoso

However, pyHook and pythoncom work only on Windows systems. Not too bad, since most computers in this world are using Windows. Tkinter is more cross-platform for the few odd folks that user other OS.

bumsfeld 413 Nearly a Posting Virtuoso

Similar to jice's code:

# simply ignore index zero
pos = ['  '] * 11
print( pos )

POS = 1

pos[POS] = '->'
print( pos )

"""my display -->
['  ', '  ', '  ', '  ', '  ', '  ', '  ', '  ', '  ', '  ', '  ']
['  ', '->', '  ', '  ', '  ', '  ', '  ', '  ', '  ', '  ', '  ']
"""
bumsfeld 413 Nearly a Posting Virtuoso

Toasted plain bagel with lots of butter and fresh cup of black tea.

bumsfeld 413 Nearly a Posting Virtuoso

It assume it to be written in a mix of C and Assemb ly code

I think this is correct, because as my father explained to me, in those days C compilers had the inline assembly language option. This allowed access to the very low levels of the computer chips.

bumsfeld 413 Nearly a Posting Virtuoso

What are you going to do to the user after 3 tries?

bumsfeld 413 Nearly a Posting Virtuoso

At least for some time, it would be very nice if people indicated which version of Python they are using.

bumsfeld 413 Nearly a Posting Virtuoso

If this is truly your text file, I feel sorry for you!

bumsfeld 413 Nearly a Posting Virtuoso

I think you need to develop mask of your image to make this work.

bumsfeld 413 Nearly a Posting Virtuoso

The Python module datetime allows you to calculate the days between two given dates with relative ease. I am using the US date format month/day/year, but you can change that by giving attention to the order of the extracted tuple.

bumsfeld 413 Nearly a Posting Virtuoso

The wxPython GUI toolkit has a nice numeric LED widget (LEDNumberCtrl from the wx.gizmos module) that is used here for displaying the current time in very visible 7 segment LED color display. It also shows the application of the time module and wx.Timer(). The code is simple as far as GUI code goes, and commented so you can study it.

bumsfeld 413 Nearly a Posting Virtuoso

Added sieve algorithm function to compare times with.

bumsfeld 413 Nearly a Posting Virtuoso

This Python snippet shows you how to take typical beginner's example of prime number function and work on improving its speed. The decorator function for timing is ideal tool to follow your progress you make. The improvements are commented and you are encouraged to make further improvements. Python is fun!

bumsfeld 413 Nearly a Posting Virtuoso

Using the wx.lib.pdfwin.PDFWindow one can read Adobe PDF files (.pdf) with wxPython. The PDF file format is popular document file format allowing mixing of text and graphics. The GUI toolkit wxPython's newer wx.activex module allows one to use the ActiveX control, as if it would be one wx.Window. It actually embeds the Adobe Acrobat Reader into the wx.Window.

bumsfeld 413 Nearly a Posting Virtuoso

The FlashWindow component of wxPython will play those nice animated flash files found on the internet. They have file extension .swf usually.

bumsfeld 413 Nearly a Posting Virtuoso

The wxPython GUI tool makes it very simple to create nice looking analog clock. The analog clock component was put into simple dialog frame and can be moved about the screen.

bumsfeld 413 Nearly a Posting Virtuoso

I can't believe it needs to be that complex!

bumsfeld 413 Nearly a Posting Virtuoso

Here we search a Python script file (or other text file) for one certain string, and copy any files containing this string to another folder.

bumsfeld 413 Nearly a Posting Virtuoso

Search for a file given its name and the starting search directory. The search is limited to a set depth of subdirectories. Python makes this easy to do.

bumsfeld 413 Nearly a Posting Virtuoso

This Python code will search for given filename starting with given directory. It will also search all the subdirectories in the given directory. The search will end at the first hit.

bumsfeld 413 Nearly a Posting Virtuoso

Code snippet to show you how to verify exit events from wxPython using dialog window. One event is from menu exit and the other from frame exit (x symbol in corner).

bumsfeld 413 Nearly a Posting Virtuoso

This short code shows how to indicate the mouse-over event on wxPython button, similar to the mouse-over in web pages. Button changes colour when mouse pointer is over its area.

bumsfeld 413 Nearly a Posting Virtuoso

The myth is around that while loop is faster than the corresponding for loop. I checked it out with Python module timeit, and came to surprising conclusion.

This snippet can easily be modified to time any of your functions you write.

bumsfeld 413 Nearly a Posting Virtuoso

This program uses Python module re for splitting a text file into words and removing some common punctuation marks. The word:frequency dictionary is then formed using try/except. In honor of 4th of July the text analyzed is National Anthem of USA (found via Google).