sneekula 969 Nearly a Posting Maven

err why dont you use just use a bit of simple logic and search it on google??if you dont believe me theres nothing i can do...its just your stupidity

Google is just a search engine, it does not verify its collection of data. So there is a huge amount of hogwash you can find there.

Salem commented: "It didn't work, I can't believe it didn't work! I found it on the Internet!" - Adam Savage, Mythbuster +17
sneekula 969 Nearly a Posting Maven

Of course that is true -- In the USA they are called senators, congressmen, and lobbyists.

Nope, they are called moneybag bankers.

techbound commented: BTW I like "No one died when Clinton lied" :) +1
sneekula 969 Nearly a Posting Maven

Higher food prices will cure obesity.

Higher petrol prices will cure obesity.

Nick Evan commented: Haha +6
sneekula 969 Nearly a Posting Maven

Fuse, very nice code ad explanation!
Python has a few string functions that make your code even easier. Simply use line.rstrip(). The default removes any trailing whitespace characters like '\n':

line = '0.00\t2.869e-12\t7.715e-08\t0.000e+00\t0.000e+00\n'
# remove any trailing whitspace characters (default)
line = line.rstrip()
line_list = line.split('\t')
print line_list  # ['0.00', '2.869e-12', '7.715e-08', '0.000e+00', '0.000e+00']
Fuse commented: thanks, didn't know that! +1
sneekula 969 Nearly a Posting Maven

sadly all of them are Jehovah's witnesses :)

I think you are right! Oops, there is a knock at the door, got to go!

thunderstorm98 commented: LOL +4
sneekula 969 Nearly a Posting Maven

I believe that the end of the world will come when people believing in different beliefs start to kill each other on a massive scale.

Something like my God is better than your God. Most likely, my God told me to kill all nonbelievers with this divine arsenal of nuclear weapons.

Salem commented: Yes, the well armed zealot is always a problem +16
sneekula 969 Nearly a Posting Maven

The difference between the short tax form and long tax form is simple:

If you use the short form, the government gets your money.

If you use the long form, the accountant gets your money.

Aia commented: Putting salt in the wound ;) +7
sneekula 969 Nearly a Posting Maven

One of the ways to do this would be:

s = "WordOneWordTwo"

new_s = ""
for ix, c in enumerate(s):
    # skip start of string s
    if c.isupper() and ix != 0:
        new_s += " "
    new_s += c
    
print new_s  # Word One Word Two
sneekula 969 Nearly a Posting Maven

Tkinter only displays gif and ppm images, to show the more popular jpg and png images you have to incorporate the Python image Library (PIL). Here is an example:

# load and display an image with Tkinter
# Tkinter only reads gif and ppm images
# use Python Image Library (PIL) for other image formats
# give Tkinter a namespace to avoid conflicts with PIL
# (they both have class Image) PIL is free from:
# http://www.pythonware.com/products/pil/index.htm

import Tkinter as tk
from PIL import Image, ImageTk

root = tk.Tk()
cv1 = tk.Canvas(root, width=500, height=500)
cv1.pack(fill='both', expand='yes')

# open a jpeg file into an image object
# image should be in the source folder or give full path name
image1 = Image.open("flowers.jpg")
# convert image object to Tkinter PhotoImage object
tkimage1 = ImageTk.PhotoImage(image1)

# tk.NW anchors upper left corner of image
# at canvas coordinates x=10, y=20
cv1.create_image(10, 20, image=tkimage1, anchor=tk.NW)

root.mainloop()
sneekula 969 Nearly a Posting Maven

We all know, but we don't do your homework! Read the DaniWeb rules.

Aia commented: Very clear +7
sneekula 969 Nearly a Posting Maven

Simple debugging using the Python debug module pdb:

# test the built-in Python Debugger (Pdb in the Python reference)
# at the debugger's '(Pdb)' prompt you can type  h  for help or
# more specifically use   h step  or   h next

import pdb

#help('pdb')

# once the '(Pdb)' prompt shows, you are in the debugger
# and you can trace through by entering:
#
# next (or n) which goes line by line and does not get
# into functions or into every iteration of a loop
#
# step (or s) which is more detailed and for instance
# loops through an entire range()
#
# so use next to get where you want to be and then use step,
# once you have all the details you need, use next again

pdb.set_trace()

# now you can test the following code ...

def hasCap(s):
    """returns True if the string s contains a capital letter"""
    for num in range(65, 91):
        capLetter = chr(num)
        if capLetter in s:
            return True
    return False

str1 = 'Only pick up strings without Capital letters!'
str2 = 'only pick up strings without capital letters!'

# test the function hasCap()
if hasCap(str1):
    print "str1 has a capital letter"
else:
    print "str1 has no capital letter"

if hasCap(str2):
    print "str2 has a capital letter"
else:
    print "str2 has no capital letter"

You need to play with this a little to get familiar with the pdb debugger.

sneekula 969 Nearly a Posting Maven

I have found some bugs just using the Python debugger module pdb:

# test the built-in Python Debugger (Pdb in the Python reference)
# at the debugger's '(Pdb)' prompt you can type  h  for help or
# more specifically use   h step  or   h next

import pdb

#help('pdb')

# once the '(Pdb)' prompt shows, you are in the debugger
# and you can trace through by entering:
#
# next (or n) which goes line by line and does not get
# into functions or into every iteration of a loop
#
# step (or s) which is more detailed and for instance
# loops through an entire range()
#
# so use next to get where you want to be and then use step,
# once you have all the details you need, use next again

pdb.set_trace()

# now you can test the following code

def hasCap(s):
    """returns True if the string s contains a capital letter"""
    for num in range(65, 91):
        capLetter = chr(num)
        if capLetter in s:
            return True
    return False

str1 = 'Only pick up strings without Capital letters!'
str2 = 'only pick up strings without capital letters!'

# test the function hasCap()
if hasCap(str1):
    print "str1 has a capital letter"
else:
    print "str1 has no capital letter"

if hasCap(str2):
    print "str2 has a capital letter"
else:
    print "str2 has no capital letter"
vegaseat commented: very nice +8
sneekula 969 Nearly a Posting Maven

joshSCH
Presently a banned member. Has the language skills of an 18th century Thames river washer woman. His posts make even iamthwee's worst contributions look like message from heaven. You want to study an unhappy person, take a look.

sneekula 969 Nearly a Posting Maven

iamthwee
Industrious Poster with a large number of reputating browny points. Very smart, but likes to egg folks on a little when he/she gets bored. May just be a perfect geek!

sneekula 969 Nearly a Posting Maven

The Dude
A real genius, makes you think and even laugh when you actually don't feel like it. I don't think he/she has not one nasty bone in his/her body! Thanks Dude!

sneekula 969 Nearly a Posting Maven

Herbert Hoover was in charge of a governmant wheat pice support program that lasted from 1915 to 1929. Any idiot that could scratch the soil eventually grew wheat and made a living. In 1929 the price support collapsed, and the price went down to $0.00 per bushel of wheat!

sneekula 969 Nearly a Posting Maven

jwenting
Don't let his sometimes rough and conservative exterior fool you, deep down he has the deepest and best sense of humour in the forum. He is an excellent programmer and knows his languages, he is at home with Java. One word of caution, don't start to talk about photography with him, it will be tough to have him stop.

sneekula 969 Nearly a Posting Maven

vmanes
Like his atavar suggests is a grandfatherly well meaning figure, always helpful and friendly. He helps folks a lot in the difficult C++ forum. I mainly know him from the lounge, but always enjoy his insights into life as it is!

sneekula 969 Nearly a Posting Maven

Just an accumulation of foolish things said by important folks on the merits of war. I am quoting the Iraq war here, but it can be contributions to any war.

There is a lot of money to pay for the Iraq war that doesn't have to be US taxpayer money, and it starts with the assets of the Iraqi people. We are talking about a country that can really finance its own reconstruction and relatively soon."
~~~ Paul Wolfowitz, March 27, 2003

Iraq is a very wealthy country. Enormous oil reserves. They can finance, largely finance the reconstruction of their own country. I have no doubt that they will.
~~~ Richard Perle, July 11, 2002

When it comes to reconstruction, before we turn to the American taxpayer, we will first turn to the resource of the Iraqi government and the international community.
~~~ Donald Rumsfeld, also March 27, 2003

Mission accomplished!
~~~ George Bush, sometime in 2003

Some facts:
Official cost of the Iraq war to US tax payers as of March 2008: $523 billion

Median household income in Cleveland: $27000
Average income of an Army private in combat: $26000
Average income of military contractor CEOs: $9095756
Highest paid military contractor CEO: $24399747 (Robert Stevens of Lockheed Martin)

vegaseat commented: very timely topic +8
sneekula 969 Nearly a Posting Maven

Here is the spiel:

a += b  Roughly equivalent to a = a + b 
a -= b  Roughly equivalent to a = a - b  
a *= b  Roughly equivalent to a = a * b  
a /= b  Roughly equivalent to a = a / b  
a //= b  Roughly equivalent to a = a // b 
a %= b  Roughly equivalent to a = a % b  
a **= b  Roughly equivalent to a = a ** b   
a &= b  Roughly equivalent to a = a & b  
a |= b  Roughly equivalent to a = a | b  
a ^= b  Roughly equivalent to a = a ^ b  
a >>= b  Roughly equivalent to a = a >> b  
a <<= b  Roughly equivalent to a = a << b
rysin commented: Helped a lot, answered question. +1
sneekula 969 Nearly a Posting Maven

This modified Tkinter GUI code allows you to follow your character key strokes on the console display:

# KeyLogger.py
# show a character key when pressed without using Enter key
# hide the Tkinter GUI window, only console shows

import Tkinter as tk

def key(event):
    if event.keysym == 'Escape':
        root.destroy()
    print event.char

root = tk.Tk()
print "Press a key (Escape key to exit):"
root.bind_all('<Key>', key)
# don't show the tk window
root.withdraw()
root.mainloop()
sneekula 969 Nearly a Posting Maven

You can use the Tkinter GUI toolkit too:

# KeyLogger.py
# show a character key when pressed without using Enter key
# hide the Tkinter GUI window, only console shows

import Tkinter as tk

def key(event):
    if event.keysym == 'Escape':
        root.destroy()
    print event.char

root = tk.Tk()
print "Press a key (Escape key to exit):"
root.bind_all('<Key>', key)
# don't show the tk window
root.withdraw()
root.mainloop()
sneekula 969 Nearly a Posting Maven

You can use the local variable dictionary vars() to create new variables on the fly:

food = 'bread'
vars()[food] = 123
print bread  # --> 123

Print vars() after line 1 and 2 to follow what's happening.

sneekula 969 Nearly a Posting Maven

Probably the easiest way to do this is to use the local variable dictionary vars() to create new variables on the fly:

food = 'bread'

vars()[food] = 123

print bread  # --> 123

You can print out vars() to see what's going on.

sneekula 969 Nearly a Posting Maven

I am working on an expert system to replace our lying and cheating political leadership with a lying and cheating computer system. :)

majestic0110 commented: hehe +1
Ancient Dragon commented: LOL :) Didn't we have a prototype in the 2000 election ? +24
sneekula 969 Nearly a Posting Maven

Are you an astronomer? No? Then STFU.

Ouch, very bad language here! Are you an astronomer, or simply got up on the wrong side of the bed?

scru commented: I alays get up in the middle, so I never run the risk :P +3
sneekula 969 Nearly a Posting Maven

"Feeling blue" comes from the Myan tradition to paint people blue before they were overed to their God in human sacrifice rituals.

sneekula 969 Nearly a Posting Maven

Even if it is, why the hell not? The MSM & the left have been doing the same for decades.

You are of course correct! If we had lots of smart and well informed voters, I wouldn't worry about it.

Dave Sinkula commented: Problem solved. :D +13
sneekula 969 Nearly a Posting Maven

28 percent of the value of gift cards and gift certificates is never redeemed.

sneekula 969 Nearly a Posting Maven

It is much easier to be critical than correct.

vegaseat commented: very true +7
sneekula 969 Nearly a Posting Maven

Thanks to the 12th Amendment we won't have to put up with an ill conceived Hill and Bill, or Dick and Bush ticket.

ZZucker commented: funny +1
sneekula 969 Nearly a Posting Maven

The children had all been photographed, and the teacher was trying to persuade them each to buy a copy of the group picture. “Just think how nice it will be to look at it when you are all grown up and say, ‘There’s Jennifer, she’s a lawyer,’ or ‘That’s Michael, He’s a doctor.’

A small voice at the back of the room rang out, “And there’s the teacher, she’s dead.”

~s.o.s~ commented: Heh +20
sneekula 969 Nearly a Posting Maven

The phonemes for Professor Stephen Hawking's computerized voice were recorded by Michael Jacobs, who is now on trial for the murder of his wife. A spokesperson for Hawking says that he has no plans to alter his voice, even if Jacobs is convicted.

sneekula 969 Nearly a Posting Maven

An attorney was sitting in his office late one night, when Satan
appeared before him. The Devil told the lawyer, "I have a
proposition for you. You can win every case you try, for the
rest of your life. Your clients will adore you, your colleagues
will stand in awe of you, and you will make embarrassing sums of
money. All I want in exchange is your soul, your wife's soul,
your children's souls, the souls of your parents, grandparents,
and parents-in-law, and the souls of all your friends and law
partners." The lawyer thought about this for a moment, then
asked, "So, what's the catch?"

sneekula 969 Nearly a Posting Maven

There is something misanthropic about cars that run on food. I can just see some rich jerk running a car on steak and eggs.

Sulley's Boo commented: :D +4
sneekula 969 Nearly a Posting Maven

Well, my dad is a very successful lawyer and has helped a lot of people in his life. Something he and I are proud off. Looks like this thread is more about envy, by folks who have an unsuccessful and poorly paying job.

Hey Lardmeister, the reason there are lawyer jokes is that the lawyers laugh at them the hardest!

Did you hear about the terrorists who took a whole courtroom full of lawyers hostage?

They threatened to release one every hour until their demands were met.

Dave Sinkula commented: Props on the joke. +12
VernonDozier commented: That one's a keeper. +1
sneekula 969 Nearly a Posting Maven

Did you know that one millionth of a mouthwash is a microscope?

The weight an evangelist carries with God is a billigram.

Ten rations are a decoration.

One million aches are a megahurtz.

The basic unit of laryngitis is a hoarsepower.

sneekula 969 Nearly a Posting Maven

Q: What can a goose do, that a duck can't do, and a lawyer should do?

A: Stick his bill up his ass.

sneekula 969 Nearly a Posting Maven

INSERT takes care of that, for example:

import Tkinter as tk

root = tk.Tk(className = " Text")

# text entry field, width=width chars, height=lines text
text1 = tk.Text(root, width=70, height=20)
text1.pack()

str1 = "First string"
str2 = "Second string"

text1.insert(tk.INSERT, str1)

text1.insert(tk.INSERT, str2)

root.mainloop()

To get the whole content of the Text widget and store it in a variable use:

# get the text from beginning to end
# line starts with 1 and column with 0
my_text = text1.get(1.0, tk.END)
Racoon200 commented: This post was very helpful, it answered the question just as planted. +2
sneekula 969 Nearly a Posting Maven

I have a dictionary of chemical symbols and names, to look up the symbol and get the name is easy, but to find the symbol of a given chemical name seems to be more akward. Am I missing something here?

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

# show the name of a symbol
symbol = 'N'
print symbol_dic[symbol]  # nitrogen
Ene Uran commented: great question +4
sneekula 969 Nearly a Posting Maven

It's possible to lead a cow upstairs, but not downstairs.

sneekula 969 Nearly a Posting Maven

James Doohan, who played Lt. Commander Montgomery Scott (Scotty) on Star Trek,
is missing the entire middle finger of his right hand.

Clotoss commented: Knows lots of facts :P +0
sneekula 969 Nearly a Posting Maven

Each king in a deck of playing cards represents a great king from history:

Spades --> King David
Clubs --> Alexander the Great
Hearts --> Charlemagne
Diamonds --> Julius Caesar

debasisdas commented: never knew that +0
sneekula 969 Nearly a Posting Maven

After reading all the mind numbing squabble in some of the more political threads, this thread is one of the more enlightening ones:

Warmed over asparagus and egg au gratin.

twomers commented: Agreed :) +3
sneekula 969 Nearly a Posting Maven

~~~ stupid idot ~~~

Do you mean ipod or IDOT (Illinois Department of Transportation)?

nav33n commented: lol ! +1
EnderX commented: I believe he meant those suffering from internal eye-dee-ten-tee errors, although I could be mistaken. +3
sneekula 969 Nearly a Posting Maven

A mother and son were walking through a cemetery, and passed by a
headstone inscribed "Here lies a good lawyer and an honest man."
The little boy read the headstone, looked up at his mother, and
asked "Mommy, why did they bury two men there?"

sneekula 969 Nearly a Posting Maven

Violence committed in the name of a religion. I have pretty well had it with this islamic crap.

Salem commented: Well said +12
sneekula 969 Nearly a Posting Maven

Two pieces of Kentucky Fried Chicken.

Water is composed of two gins, Oxygin and Hydrogin. Oxygin is pure gin. Hydrogin is gin and water.

~s.o.s~ commented: Heh, good one. +20
sneekula 969 Nearly a Posting Maven

Oh my, still eating food and drinking water.

You live in India and drink the water, isn't that dangerous? I hope you boil it thoroughly first.

~s.o.s~ commented: You started it. There was no need to splash mud on our country like that. We know what goes around here better than you. +20
sneekula 969 Nearly a Posting Maven

To all my friends who sent me best
wishes for 2007, they did nothing. For
2008, could you please send either
money, alcohol or petrol vouchers.
Cheers!

darkagn commented: Haha +1