Just read this:
"Socialism is the opiate of the masses."
Here I thought it was Religion for so many years.
ZZucker 342 Practically a Master Poster
vegaseat commented: very nice example +8
Just read this:
"Socialism is the opiate of the masses."
Here I thought it was Religion for so many years.
With Python that is a simple task:
import os
# list just the files in a given folder
folder = 'C:/Temp'
for (paths, dirs, files) in os.walk(folder):
# testing, this shows a list of filenames
print files
# now loop through the list of filenames
for filename in files:
# testing
print filename
# now enter code to process each of your files
# ...
Using the Tkinter or the wxPython GUI toolkit, design a program that uses sliders to change the RGB values of a sample label's background color and its text (foreground) color in real time. Once you are happy with the colors, allow it to save the rgb values to the clipboard so they can be used in a program.
This Python snippet might be of help:
http://www.daniweb.com/code/snippet457.html
Oh, how sweet it is of you to think of your mother on her special day!
Believing in Angels and Ghosts is very popular in the USA. Are these just local phenomena, or do other countries suffer from that?
Paranormal experts say the peak of people's ability to see ghosts is when they're 7 years old.
Paranormal experts say the peak of people's ability to see ghosts is when they're 7 years old.
Sorry, I put this in here by accident, but then it could fit here just as well.
ok I used:
diffInstance = difflib.Differ() diffList = list(diffInstance.compare(list1, list2))
and this returns a list of words with + - before them. As I read and understand probably - means just list1 has the word, and + that just list2 has the word. And I'm not getting and similar words, maybe I'm doing something wrong, can you help me a little bit. Also I'm new to python, I'm working in it just few months
I modified one of vegaseat's Python snippets in the hope it will help you:
# find the difference between two texts
import difflib
text1 = """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 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 Owl Recipes by the EPA
The Engineer's Guide to Passion
Ralph Nader's List of Pleasures
"""
# create a list of lines in text1
text1_lines = text1.splitlines(1)
# dito for text2
text2_lines = text2.splitlines(1)
diff_instance = difflib.Differ()
diff_list = list(diff_instance.compare(text1_lines, text2_lines))
print "Lines in diff_list …
Never trust a thin chef.
(French Proverb)
Fingerprints are known to change slowly over time. After 15 years an individual's fingerprints will only retain 80 percent of their earlier characteristics.
Maybe Microsoft realized that they better bring out a new decent operating system after that Windows Vista disaster. Rather than to muck up the lives of all those talented folks at Yahoo.
I have to admire you Brits, you won that Falklands War despite all odds, and got rid of a very brutal military dictatorship in Argentina at the same time. Success all around, that's the way to do it, congratulations!
Come to think of it, you had great leadership in those days.
I listened to Johnson's speech -- very funny man. He promised to build 50,000 public homes. We tried that in USA too and it was a disman failure. The homes were turned into slums in very quick time.
However, in the USA it was the federal government that did this, and we all know they can't do anything right. I think it is mainly because all the politicos involved (plus friends and relatives) have their hand in the till. On a lighter note, you are correct JB, great hair!
Most of my rather simpleminded and
pointles posts are in the lounge.
1000 posts is a milestone and the next
real milestone is 20,000 posts. So LOL
your way up there and you can be first.
Got to leave now to have some fun!
Great stuff AD!
Think about it, women can form a new human being, a God-like endeavor indeed. Men could help by doing some of the houshold chores at least.
Whatever happened to Preparations A through G?
After all this 'Godly' talk, I have to restate my passion a little. I intend to live life to its fullest. Heaven and Hell are all part of being alive, when you die then the curtain closes, the lights go out, and so do your senses. It's going to be just a peaceful dark, no Heaven and no Hell.
Strawberries and cream, refreshing!
Actually, I don't think USA should be giving military aid to anyone at all. Bring all our military home from around the world and let everyone fight their own battles. We are not (or should not be) the world police. This planet got along just fine for thousands of years without the USA.
Wishful thinking AD! In the old days when battles were fought on foot or on horse, distance helped to separate us from the silly folks that did the fighting. Now with rockets and weapons of mass destruction readily at hand, you need a world policeman. You don't need some trigger-happy cowboy or cowgirl to play the role, but a person that can make sense to the parties involved.
Using a list would make your code shorter:
"""
charRun = 1
charRun1 = 0
charRun2 = 0
charRun3 = 0
charRun4 = 0
charRun5 = 0
charRun6 = 0
charRun7 = 0
charRun8 = 0
charRun9 = 0
charRun10 = 0
charRun11 = 0
charRun12 = 0
charRun13 = 0
charRun14 = 0
charRun15 = 0
"""
# the above cries out for a list
charRun = [1] + [0]*15
# test it ...
print charRun # [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
print charRun[0] # 1
print charRun[5] # 0 same as charRun5 in your code
"""
if charRun12 == 37:
if charRun13 <= 36:
charRun13 = charRun3 + 1
charRun12 = 1
charRun11 = 1
charRun10 = 1
charRun9 = 1
charRun8 = 1
charRun7 = 1
charRun6 = 1
charRun5 = 1
charRun4 = 1
charRun3 = 1
charRun2 = 1
charRun1 = 1
charRun = 1
"""
# here you do something like
charRun[12] = 37 # for testing only
if charRun[12] == 37:
if charRun[13] <= 36:
charRun[13] = charRun[3] + 1
for k in range(13):
charRun[k] = 1
# test it ...
print charRun # [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]
Hey vegaseat, thanks for the UliPad reference. I installed it on my Windows Vista machine, and I like it, particularly the snippet manager. Hopefully, it will work equally well for FreezeBlink on his/her Ubuntu machine! It works with a number of computer languages, and recognizes the code by its file extension.
Thanks for the help vegaseat now i know i need to practice Python more...but one more thing. When ever i put this in my elif statement
elif direction == '2':
The program stops from their. Any suggestions?
Thanks
I think you misunderstood vegaseat. It needs to be something like this:
print "Welcome to Adventure!"
print " "
print "Your options are: "
print "1) Play"
print "2) Quit"
choice = raw_input("Choose your option (1, 2): ")
if choice == '1':
#print "You can go: "
dir_list = ['N', 'S', 'E', 'W']
direction = raw_input("Where do you want to go (N, S, E, W)?: ").upper()
if direction in dir_list:
# do something here
pass # temporary action
elif choice == '2':
print "You find nothing.."
Another example is OpenOffice, it is written in Java but uses Python as an internal scripting language.
The nice thing about OpenOffice is that Sun makes it available for free (if you like it make a donation) and it competes very well with Microsoft Office. I have had no problems using my old MS Office files.
My folks had a few Flinstone tapes around when I grew up. I have to admit that the Simpsons have class! Besides most of my teachers hated the Simpsons.
Conversely, please accept that some of us do not. Our simple request is that need be kept as a personal matter and out of our schools, laws, government, and international dealings. Simple enough from our point of view anyway, obviously not so for the majority.
Amen to that! For those of you who believe in God, in God's view we might just be an experiment gone wrong. There might only be one God, but many more experiments with mankind. Maybe some of them might be just a bit more perfect.
What hair color do they put on the driver's licenses of bald men?
Well, the Jewish people needed a home state after suffering many centuries of persecution in countries like Italy, Spain, Russia and Germany. So, their original home came to mind.
I admit, the Arabs got a raw deal, but then they are a strange lot to deal with.
The socalled Miracle Marine, who survived being burned over more than 95 percent of his body in Iraq and established a charity to help burned children has died, the military has announced. Now there is a hero!
When I grow up I wouldn't mind to look like Betty Rubble.
Nothing is particularly hard, if you divide it into small jobs.
And just which variant of Cole's Law would that be?
I know only one variant, Cole's Law: "Thinly Sliced Cabbage"
I think women live longer than men because we were an upgraded model of the human being.
Watching an hour-long soap opera burns more calories than watching a three-hour baseball game.
Why send a perfectly good gay to another country to have him killed?
Grilled artichoke and parmesan dip on garlic and herb crackers. My folks had a big party last night and these are leftovers.
Gee Lardy, your folks slip you some nice leftovers! I would have to make napkin soup at my house. My folks only invite people that eat absolutely everything in sight!
Divide and rule!
Unite and lead!
I wonder which motto is the better one?
Women like silent men. They mistakingly think that they're listening.
Researchers at Carnegie Mellon University have determined that 65 percent of cats' dreams are nightmares.
Any sewer plant is essentially a composting facility.
All politicians get money in return for political favors! That's the idea!
Give us some idea what the file looks like, and we go from there. In Python you can simply establish a structured record for each customer with a class. I think there are some examples in the Python code snippets. Take a see here:
http://www.daniweb.com/code/snippet355.html
If you really want to sink your teeth into it, you can use a database like sqlite3 that is built into Python25 and later.
BTW, updating the display screen continuously will be the slowest part of your program.
You could write it something like this, where the game is in a function that gets called from the loop:
# Rock, Paper, Scissors game
import random
def game(win, lose, tie):
print \
'''
a - Rock
b - Paper
c - Scissors
'''
player = raw_input("Choice (a, b or c): ").lower()
print
if player == 'a':
print 'You picked rock'
elif player == 'b':
print 'You picked paper'
elif player == 'c':
print 'You picked scissors'
computer = random.choice(['a', 'b', 'c'])
if computer == 'a':
print 'Computer picked Rock'
elif computer == 'b':
print 'Computer picked Paper'
elif computer == 'c':
print 'Computer picked Scissors'
if player == 'a' and computer == 'c':
win += 1
print 'Rock crushes scissors...You WIN this round!'
elif player == 'c' and computer == 'b':
win += 1
print 'Scissors cuts paper... You wIN this round!'
elif player == 'b' and computer == 'a':
win += 1
print 'Paper wraps up that rock...You wIN this round!'
elif player == computer:
tie += 1
print "It's a tie!"
else:
lose += 1
print 'YOU LOSE!!!'
return win, lose, tie
win = 0
lose = 0
tie = 0
games = 0
while True:
win, lose, tie = game(win, lose, tie)
games += 1
print "Games =", games
print "Wins =", win, "Loses =", lose, "Ties =", tie
# stop after 10 games
if games >= 10:
break
raw_input("Thank you for playing! Press enter ... ")
I think you want module curses, that one has setsyx(y, x) that puts the cursor to where you want to print on the screen.
When I resize the frame it works just fine.
It might be these two lines that give you problems with a larger picture:
self.panel_1.SetMinSize((480, 272))
self.panel_1.SetMaxSize((480, 272))
When you draw your crosshairs, you have to reference the image height and width:
def lineaorizzontale(self, y):
self.dc.SetPen(wx.Pen('blue', 1))
w = self.image.GetWidth()
#print w
self.dc.DrawLine(0, y, w, y)
def lineaverticale(self, x):
self.dc.SetPen(wx.Pen('blue', 1))
h = self.image.GetHeight()
#print h
self.dc.DrawLine(x, 0, x, h)
---
I showed Dave Sinkula my picture and he tried to convince me that I don't really have blonde hair...
Just a cheap ploy by some guys to get more proof. You know. Blondes and redheads suffer from that most often.
Just a basic Python class example to show you how you can work with it:
# basic experiments with Python class
class Cat(object):
# this is public
cost = 100
# this is private to the class
__price = cost + cost * 0.25
# constructor
def __init__(self, num=1):
self.num = num
self.sound = "meow " * self.num
print self.sound
def own(self):
print "I own", self.num, "cats"
def paid(self):
self.total = self.__price * self.num
print "I paid", self.total, "for my cats"
def kitten(self):
self.kit = 5
print "One cat just had", self.kit, "kittens"
return self.kit
class Dog(object):
# this is public
cost = 400
# this is private to the class
__price = cost + cost * 0.25
# constructor
def __init__(self, num=1):
self.num = num
self.sound = "woof " * self.num
print self.sound
def own(self):
print "I own", self.num, "dogs"
def paid(self):
self.total = self.__price * self.num
print "I paid", self.total, "for my dogs"
class Pets(Cat, Dog):
"""class Pets inherits class Cat and class Dog"""
# constructor
def __init__(self):
self.num = cat.num + dog.num
self.sound = cat.sound + dog.sound
print self.sound
def own(self):
print "I own", self.num, "pets"
def paid(self):
print "I paid", dog.total + cat.total, "for my pets"
def update(self):
# notice how Pets inherited kitten() from class Cat
self.kit = self.kitten()
print "So now I have", self.num + self.kit, "pets"
cat = Cat(3)
cat.own()
cat.paid()
print '-'*30
dog = Dog(2)
dog.own()
dog.paid()
print '-'*30
pets = Pets()
pets.own()
pets.paid()
print '-'*30
pets.update()
"""
my output --> …
What does not work properly?
What do you expect to happen?
If you make a copy of a list, and you have a nested list or don't know what the list might be in the your program, always use module copy:
# make a true copy of a nested list
import copy
nested_list = [1, [2, 3], 4]
copied_list = copy.deepcopy(nested_list)
# a regular list copy looks alright at first
copied_list2 = nested_list[:]
print nested_list # [1, [2, 3], 4]
print copied_list # [1, [2, 3], 4]
print copied_list2 # [1, [2, 3], 4]
print '-'*20
# change the orignal list
nested_list[1][0] = 99
# but the test shows a surprise!
print nested_list # [1, [99, 3], 4]
print copied_list # [1, [2, 3], 4]
# with simple copy the inner list is just an alias
print copied_list2 # [1, [99, 3], 4] oops!
You have to be careful not to create a list alias. Something you do inadvertantly with a nested list:
# make a true copy of a nested list
import copy
nested_list = [1, [2, 3], 4]
copied_list = copy.deepcopy(nested_list)
# a regular list copy looks alright at first
copied_list2 = nested_list[:]
print nested_list # [1, [2, 3], 4]
print copied_list # [1, [2, 3], 4]
print copied_list2 # [1, [2, 3], 4]
print '-'*20
# change the orignal list
nested_list[1][0] = 99
# but the test shows a surprise!
print nested_list # [1, [99, 3], 4]
print copied_list # [1, [2, 3], 4]
print copied_list2 # [1, [99, 3], 4] oops!
This works just fine for me using a Windows Vista machine:
lines = file('./simple-retrieval/file1.txt', 'r').readlines()
# show the first 10 lines for a test
print lines[:10]
del lines[0:4]
# now show the first 10 lines for a test
print lines[:10]
file('./simpleunwrapped/file2.txt', 'w').writelines(lines)