bumsfeld 413 Nearly a Posting Virtuoso
Try self.SetSizerAndFit(sizer)
So, what good anti-virus programs are out for Windows 7?
Should be at least 1 kilometer in diameter before it's worth one Hollywood movie!
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.
You know you are complete computer geek when you like Google's new language Go.
It is better to die for something than to live for nothing.
-- George S. Patton (US Army)
Are you usng Python2 or Python3?
Are your positive numbers integers or floats?
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
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!
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'.
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.
You may not want to add letters to the list that have zero count.
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.
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!
Seems to me that you also have to consider the time that re.compile() needs.
Some corrections:
num = 0
mylist = []
while num < 10:
num = num + 1
mylist.append(num)
print(mylist)
for item in mylist:
print(item)
Okay that was quit stupid :f
Asking questions is never stupid! :)
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
# 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/
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!!
Apple Pie + Apple Cider.
Can Halloween be far away?
I like apple dumplings and fritters! Apple cider only if it's hard cider.
As performance is concerned, the file read from disk will be the slowest part by far!
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
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
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!
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.
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.
Similar to jice's code:
# simply ignore index zero
pos = [' '] * 11
print( pos )
POS = 1
pos[POS] = '->'
print( pos )
"""my display -->
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
[' ', '->', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
"""
Toasted plain bagel with lots of butter and fresh cup of black tea.
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.
What are you going to do to the user after 3 tries?
At least for some time, it would be very nice if people indicated which version of Python they are using.
If this is truly your text file, I feel sorry for you!
I think you need to develop mask of your image to make this work.
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.
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.
Added sieve algorithm function to compare times with.
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!
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.
The FlashWindow component of wxPython will play those nice animated flash files found on the internet. They have file extension .swf usually.
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.
I can't believe it needs to be that complex!
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.
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.
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.
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).
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.
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.
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).