If it's like the like() function in VB, then you can do it with module re, which does have wildcard and characterlist patterns.
If it's like the like() function in VB, then you can do it with module re, which does have wildcard and characterlist patterns.
Every three days? Consider yourself lucky and let's leave it at that.
I agree, my cplusplus eats two rats a day, and I had to move to the inner city so it wouldn't starve!
Not if Iran wipes us off the map first :)
I read that Hillary's remark was in regard to Iran attacking Israel. One way to get Jewish votes and sound tough at the same time. Poor Obama, he looks like a naive Sunday school teacher.
To wipe the USA off the map would take well over 10,000 nuclear bombs of the primitive type Iran would produce.
Just finished a pork chop and two eggs sunny side up. This old fashioned south side diner has great java.
I am not supposed to eat pork, but have done it a few times and lightning has not struck me!
Tomatoes contain more vitamins relative to their mass than any other vegetable or fruit.
VegaSeat, like you new arty avatar!
It is not what happens to you but how you respond to what happens to you that determines how you feel.
I drink to that!
Never answer an anonymous letter.
I don't see any new avatars. Just a couple of old ones that have been adopted.
In a nutshell:
def add(a, b):
return a + b
var = 2
str = "var = add(2, 3)"
# execute the code snippet inside the str string variable
exec(str)
print var # --> 5
In Finland they banned Donald Duck comics because he doesn't wear pants.
I love deadlines. I especially like the whooshing sound they make as they go flying by.
80 percent of car trips in the United States are less than one mile in distance.
I guess whether or not you like a commercial is still a matter of taste. I think commercials make watching TV at least a little interesting.
Why do psychics have to ask your name?
When no one trusts, does it matter that everyone lies?
Why is abbreviation such a long word?
Your exploration could aid other folks. Just remember that Python style recommends to have class names begin with upper case and function/method names to begin with a lower case letter.
You can run the command window from python and obtain the results and error messages:
# run DOS cmd.exe from Python code
# works on XP, but may not work on Windows Vista
import subprocess
cmd = "cmd.exe"
command = "dir c:"
p = subprocess.Popen(cmd,
shell=True,
#bufsize=1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
# the \n is important to flush buffer
p.stdin.write("%s\n" % command)
p.stdin.close()
# give it enough time to respond
p.wait()
# optional check (0 = success)
print p.returncode
# read the result to a string
result = p.stdout.read()
print result
# optionally read any error message returned
error = p.stderr.read()
print "error =", error
Two possibilities exist: Either we are alone in the Universe or we are not. Both are equally terrifying.
Edgar Allan Poe was kicked out of West Point.
Women need a reason to have sex. Men just need a place.
quote by Billy Crystal
A rabbi and a minister were at the neighbourhood picnic. As they rode in one of the boats on the lake, the rabbi stood up, stepped out of the boat, and walked over the water to the nearby stretch of land.
Astonished, the minister decided to see if he could duplicate this miraculous feat. He stepped out of the boat and sank, but managed to swim ashore.
As he stood there drying himself off, the rabbi walked over and said, "Next time ask me first, and I will show you where the rocks are!"
It is better to fail in originality than to succeed in imitation.
Now you know why so many folks watch TV because of the commercials rather than the lousy content of the program.
Nearly 35% of self-professed Christians believe that it was Jesus, not Moses, who parted the Red Sea. Only 1% of Jews make the same mistake.
Please use code tags around your Python code to preserve the proper indentations. Check the message in the background of the Quick Reply message box for the code tags.
Do you just want to know if they are equal? If that is the case, you can simply use:
# compare two files and check if they are equal
# files can be binary or text based
import filecmp
# pick two files you want to compare ...
file1 = "Boing1.wav"
file2 = "Boing2.wav"
if filecmp.cmp(file1, file2):
print "Files %s and %s are identical" % (file1, file2)
else:
print "Files %s and %s differ!" % (file1, file2)
I think vegaseat had this posted some time ago, read the comments for instructions:
# Py2Exe version 0.6.3 setup file for console programs.
#
# If this is a windows GUI application replace the last line with
# windows = [{"script": 'myFile.py'}] )
#
# Enter the file name of your own .py code file in the last line,
# lets say it's test1.py
# so the last line should be: console = [{"script": 'test1.py'}] )
# then save this program as p2e_test1.py to the same directory
# where your code file is located.
#
# Now run p2e_test1.py ...
#
# Two subfolders will be created, called build and dist.
# The dist folder contains your .exe file, MSVCR71.dll and
# w9xpopen.exe (needed for os.popen() only)
# Your .exe file contains your byte code, all needed modules and
# the Python interpreter.
# The MSVCR71.dll can be distributed, but is often already in the
# system32 folder.
# The build folder can be deleted.
from distutils.core import setup
import py2exe
import sys
# no arguments
if len(sys.argv) == 1:
sys.argv.append("py2exe")
# creates a standalone .exe file, no zip files
setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 1}},
zipfile = None,
# replace myFile.py with your own code filename here ...
console = [{"script": 'myFile.py'}] )
Only in Japan would folks be polite enough not to kill this dude.
US $100 bills of series 2003A and later will not burn! (I have not tried this yet!)
Bill Gates made his fortune with Microsoft, but is investing it elsewhere through his investment vehicle 'Cascade Investment', like Mexican brewer Fomento Económico Mexicano.
Geek Girls Kick Ascii!
Coffee, Chocolate, Men
are best when rich
When women are depressed they either eat or go shopping. Men just invade another country.
-- Elayne Boosler
Somewhat repugnant! Do they teach that sort of skill in public school?
Wow Zoe, very nice write about John McCain.
Watching McCain on TV, is this man lacking from coherence? He seems to mix up his Iraq and Iran items and needs to be corrected by invided people around him.
Aren't you glad we have Senator Lieberman around to whisper in his ear?
This year, thanks to George Bush, after we file our taxes we all get back around $500, starting May, so we can stimulate the Walmart economy.
The General:
"All our extra scacrifice in stabilizing Iraq has worked! However, if we leave, it will all fall apart."
The happiest people don't necessarily have the best of everything. They just make the best of everything.
(Jewish proverb)
The Pope contacted all of his Cardinals with the urgent message, "Get to Rome as quickly as you can!"
Once there he assembled them and said, "I'm afraid I've got some good news and some bad news. First the good news; God spoke to me on the phone and told me that the world was going to end this Friday, and we should prepare our congregations."
"Excuse me, Your Holiness," queried a Cardinal, "If that is the good news, what could the bad news possibly be?
"He was calling from Mecca!"
If electricity comes from electrons, does morality come from morons?
Please use code tags to mainain proper Python indentations!
def my_f(modelfilename):
modelfile = open(modelfilename)
modelline_list = modelfile.readlines()
modelfile.close()
itemY = ["lol", "young", "HoLa", "...", "Yum!",
":o)", "blokes", "!!!", "hello"]
itemO = ["old", "yes", "Mom", "serious", "blog"]
for line in modelline_list:
for itemy in itemY:
if itemy in line:
print "+1 young"
# not sure if this is what you want?
return line
else:
print "-1 old"
Read line 8 and 9, you got to have the properly named icon image file for this to work.
Give module subprocess a try, it's a bit more advanced:
import subprocess
# execute the code and pipe the result to a string
test = "ping xxx.xxx.xxx.xxx"
process = subprocess.Popen(test, shell=True, stdout=subprocess.PIPE)
# give it time to respond
process.wait()
# optional check (0 --> success)
print process.returncode
# read the result to a string
result_str = process.stdout.read()
# test it ...
print result_str
You can use a similar concept as shown in the entry case, using a name_list.
Give this a try:
import random
data = ["apple", "orange", "melon", "pear"]
# this picks one item from the list above
print random.choice(data)
With Python you can use the slicing operator to help out:
t1 = '1230' # --> 12:30
t2 = '100' # --> 1:00
# slicing operator seq[begin : end : step]
# step is optional
# defaults are index begin=0, index end=len(seq)-1, step=1
# -begin or -end --> count from the end backwards
# step = -1 reverses sequence
hr1 = t1[:-2]
mn1 = t1[-2:]
print hr1, mn1 # test --> 12 30
hr2 = t2[:-2]
mn2 = t2[-2:]
print hr2, mn2 # test --> 1 00