bumsfeld 413 Nearly a Posting Virtuoso

There is just one thing I can promise you about the outer-space program - your tax-dollar will go further.
-- Wernher von Braun

bumsfeld 413 Nearly a Posting Virtuoso

Is the zebra considered black or white?

bumsfeld 413 Nearly a Posting Virtuoso

Once k gets past the number of available elements in your list you will get an IndexError. You can put in series of if statements making sure that k does not exceed the length of your list, or simply trap the error to break out of the while loop:

list2 = [23, 764, 12, 54, 83, 2, 543, 890, 1235, 453, 98]

width = 5  # experiment with this value

k = 0
while True:
    try:
        print str(list2[k]).ljust(width),
        k = k + 1
        print str(list2[k]).ljust(width),
        k = k + 1
        print str(list2[k]).ljust(width),
        k = k + 1
    except IndexError:
        break
    print

last = list2[-1]
bumsfeld 413 Nearly a Posting Virtuoso

A man went into a restaurant and ordered his meal. When the waitress came out with his soup, he noticed that she had her thumb stuck into it.

"Goddammit," said the man, "get your damn thumb out of my food!'

"Well, I injured it a while ago and the doctor said I should keep it warm."

"Why don't you just shove it up your ass?" the man said angrily.

"That's what I do when I'm in the kitchen."

bumsfeld 413 Nearly a Posting Virtuoso

The freedom to make mistakes is pricey.

bumsfeld 413 Nearly a Posting Virtuoso

Does drinking Budwiser turn you into a Smartass?

bumsfeld 413 Nearly a Posting Virtuoso

The classic Bushism by George W. Bush (Washington, DC 04/03/2004):
"I hope I -- I don't want to sound like I've made no mistakes. I'm confident I have. I just haven't -- you just put me under the spot here, and maybe I'm not as quick on my feet as I should be in coming up with one."

bumsfeld 413 Nearly a Posting Virtuoso

Patriotism is the last refuge of the scoundrel.
-- Samuel Johnson

bumsfeld 413 Nearly a Posting Virtuoso

Only one worker died on the job during the two year construction of the Eiffel Tower.

bumsfeld 413 Nearly a Posting Virtuoso

According to newspaper reports one Italian cheese factory over a two year period has recovered 11000 tons (!) of spoiled cheese and reworked it into their Mozzarella and Gorgonzola cheese, maggots and all! I guess I won't eat any pizza for a while.

Just had two doughnuts and big mug of fresh Columbian coffee to wash this story down.

bumsfeld 413 Nearly a Posting Virtuoso

I don't need a lawyer to tell me what I cannot do. I hire him to tell me how to do what I want to do.
-- J. P. Morgan

bumsfeld 413 Nearly a Posting Virtuoso

According to a recent Pew Research Center poll, the US Congress has a remarkable 41% approval rating amongst voters.

bumsfeld 413 Nearly a Posting Virtuoso

If you are born poor, you started with zero luck ... but if you die poor, you used up your luck properly according to Zen.

bumsfeld 413 Nearly a Posting Virtuoso

Whether or not we can be ever fully safe is up -- you know, is up in the air.
--George W. Bush (10/27/2004 interview with Sean Hannity)

One of my favorites spoken by George W. Bush in Portsmouth, NH on 11/01/2002:
"These people don't have tanks. They don't have ships. They hide in caves. They send suiciders out."

I also like this one where he compares himself to the Almighty (Los Angeles, CA 03/03/2004):
"God loves you, and I love you. And you can count on both of us as a powerful message that people who wonder about their future can hear."

bumsfeld 413 Nearly a Posting Virtuoso

Q: "How many blonde jokes are there?"
A: "One. The rest are all true stories."

bumsfeld 413 Nearly a Posting Virtuoso

Sneekula left one small starter editor somewhere around DaniWeb. So I took it and modified it to use the wxPython toolbar with icon images rather than Snee's menu bar. The images come from wxPython's builtin art library:

# the start of one small text editor with toolbar and image icons
# notice that the wx.TextCtrl() surface has already some advanced
# features: select text, right click to cut, copy and paste etc.

import os
import wx

class MyFrame(wx.Frame):
    def __init__(self, title):
        wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(500, 300))
        self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)

        # statusBar at the bottom of the window
        self.CreateStatusBar()
        self.SetStatusText(" Click on the icon")

        # ToolBar at the top of the window
        toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL|wx.NO_BORDER)
        toolbar.SetToolBitmapSize(size=(24,24))
        toolbar.AddSimpleTool(wx.ID_OPEN, self.getBMP(wx.ART_FILE_OPEN),
            "Load", " Load a text file")
        toolbar.AddSimpleTool(wx.ID_SAVE, self.getBMP(wx.ART_FILE_SAVE),
            "Save", " Save the text file")
        toolbar.AddSimpleTool(wx.ID_ABOUT, self.getBMP(wx.ART_INFORMATION),
            "About"," About message")
        toolbar.AddSeparator()
        toolbar.AddSimpleTool(wx.ID_EXIT, self.getBMP(wx.ART_QUIT),
            "Exit"," Exit the program")
        toolbar.Realize()
        self.SetToolBar(toolbar)

        # bind the various toolbar icon click events to some action
        self.Bind(wx.EVT_TOOL, self.onLoad, id=wx.ID_OPEN)
        self.Bind(wx.EVT_TOOL, self.onSave, id=wx.ID_SAVE)
        self.Bind(wx.EVT_TOOL, self.onAbout, id=wx.ID_ABOUT)
        self.Bind(wx.EVT_TOOL, self.onExit, id=wx.ID_EXIT)

    def getBMP(self, pic_id):
        """get the bitmap image from the wxPython art provider"""
        return wx.ArtProvider.GetBitmap(pic_id, wx.ART_TOOLBAR, wx.Size(24, 24))

    def onAbout(self, e):
        """ the about box """
        about = wx.MessageDialog( self, " A very simple text editor \n"
            " using the wxPython GUI toolkit", "About Simple Editor", wx.OK)
        about.ShowModal()
        about.Destroy()

    def onLoad(self, e):
        """ open text file"""
        self.dirname = ''
        mask = "Text (.txt)|*.txt|All (.*)|*.*"
        dlg = wx.FileDialog(self, "Choose a file to load",
            self.dirname, "", mask, wx.OPEN)
        if …
bumsfeld 413 Nearly a Posting Virtuoso

Isn't Reagan the president who destroyed the US Public Health system, sold missiles to Iran to use the money to support the 'terrorist' Contras, fired the entire Air Traffic Control workforce (95% of the replacements are coming up for retirement soon, all pretty much at the same time), I could go on but I might be shouting into the abyss on this one.

With time people say nasty things about any president. Look at George Bush, the almost perfect president, yet there's few folk still unhappy with him.

bumsfeld 413 Nearly a Posting Virtuoso

The June 11 NBC News/Wall Street Journal poll:
Obama leads McCain among registered voters, 47 to 41 percent.

That proves that McCain is not just another Bush, otherwise he should be around 28 percent.

bumsfeld 413 Nearly a Posting Virtuoso

If MyClass1.py is in the working directory, you shouldn't need to worry, since the first entry in PYTHONPATH is the present directory. Your problem is the
import MyClass1:
Python now looks for the file MyClass1:.py and of course can't find it.

Want to take a look at PYTHONPATH? Here it is:

# show the system path for Python = PYTHONPATH

import sys
print sys.path
print
print "The present working directory:"
print sys.path[0]
bumsfeld 413 Nearly a Posting Virtuoso

The way you are importing to need to use
Object1.Object1.printDamnIT()
to give the namespace too.

bumsfeld 413 Nearly a Posting Virtuoso

Well, if you do web-page designing, you will be familiar with the repeating image tile wallpaper. You can do something similar to give your wxPython frame or panel very sexy backgrounds. I leaned on one of vegaseat's snippets to come up with this example:

# wallpaper wxPython panel using one image as repeating tile
# (image is obtained from base 64 encoded png image string)

import wx
import cStringIO
import base64


class MyPanel(wx.Panel):
    """ 
    class creates panel for the tile image contained in data_stream
    """
    def __init__(self, parent, id, frame_w, frame_h, data_stream):
        # create the panel
        wx.Panel.__init__(self, parent, id)
        # frame/panel width and height
        self.frame_w = frame_w
        self.frame_h = frame_h

        # convert to bitmap
        self.bmp = wx.BitmapFromImage(wx.ImageFromStream(data_stream))
        # do the wall papering on the PaintDC canvas...
        wx.EVT_PAINT(self, self.on_paint)
        # now put some widgets on top of the panel's wallpaper
        self.button1 = wx.Button(self, -1, label='Button1', pos=(15, 10))
        self.button2 = wx.Button(self, -1, label='Button2', pos=(15, 45))
        
        
    def on_paint(self, event=None):
        # create the paint canvas
        dc = wx.PaintDC(self)
        dc.Clear()
        # get image width and height
        image_w = self.bmp.GetWidth()
        image_h = self.bmp.GetHeight()
        # use repeating image tiles to wallpaper the canvas
        for x in range(0, self.frame_w, image_w):
            for y in range(0, self.frame_h, image_h):
                dc.DrawBitmap(self.bmp, x, y, True)


# the base64 encoded png image string
png_b64='''\
iVBORw0KGgoAAAANSUhEUgAAAGQAAABkBAMAAACCzIhnAAAAMFBMVEUEAgQEAoYEAkgEAsYEAicE
AqgEAmkEAucEAhgEApgEAlkEAtYEAjgEArkEAnsEAvxjNQuZAAAFBUlEQVR4nNWXT2gcVRjAv91O
l+kyjd02kSSFYY21CtpUGIKHMGTBFkIpgVAeMpFtNlZi20MEc5jDHrKtRXOQ4LYGHA/rKuhBNB4W
CXQM2QY9GEWEdSgxPLsvhNBoO6Gp6dI/OH5vN7U97XsD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IPUkEKDzIQpDCMDkZAExnPhkf80lP7J
EKfXRs8eP4Nyl5IFxsDmX3jPskS7Gmfe1UYIma9B1p0zqIzc1Z2LixpkswbP4gjt5uE2tGHcNWja
cfIXRcjk/oZB2mCbRg/KXUJC7r6vJ8lCCY0o7VgFGbk72iis1Gv2YCtMSiGHsS4XXEqnl5y8nNy1
BDYW5lbQu5w8k1uKfXYWezHpkoVGJPf6PWFnS1Cpe5eus5QMos26Lsw16lrxTwtOq+8tLCyOXsIs
tIeQjnU9M9J0ysfGfJ/roK4fcoGml3iW5MBYM+SnGb0ejCkGmEvTToL5mdhYuWldnOlwHHaIArXw
tugj5bhfbIpEdf3mRNY2zAp4noOeehA0kQ8+pbcl1rlBQsNTUe46BYjm+/q6W5qjMPSDc1LvzEn4
4BR28+pchcJvmqPz/yjKjeav8mR/Nw55n2l6MATdut4q1q7zdUm/iX9qEIkyVuVyJ7jLjJ0eYd/h
JQZpubvCqnE99Uya/APf6sMx1/lYCAAAAABJRU5ErkJggg==
'''

# convert to png image bytes
png_bytes = base64.b64decode(png_b64)
# convert png bytes …
bumsfeld 413 Nearly a Posting Virtuoso

Ion propulsion systems under development at NASA accelerate slower than an average automobile, but can reach top speeds over half the speed of light on long trips.

bumsfeld 413 Nearly a Posting Virtuoso

Nice stuff there Fuse and Ene!
Here is my contribution, showing you how easy it is to have wxPython display an image from image file:

# show  .jpg .png .bmp or .gif image on wx.Panel

import wx

class ImagePanel(wx.Panel):
  """ create the panel and put image on it """
  def __init__(self, parent, id):
    # create the panel, this will be self
    wx.Panel.__init__(self, parent, id)
    try:
        # pick your image file you have in the working folder
        # or use the full file path
        image_file = 'strawberry.jpg'
        bmp = wx.Bitmap(image_file)
        # show the bitmap, image's upper left corner anchors
        # at panel coordinates (5, 5), default is center
        wx.StaticBitmap(self, -1, bmp, (5, 5))
        # show some image information
        info = "%s  %dx%d" % (image_file, bmp.GetWidth(), bmp.GetHeight())
        # the parent is the frame 
        parent.SetTitle(info)
    except IOError:
        print "Image file %s not found" % imageFile
        raise SystemExit


# redirect=False sends stdout/stderr to the console window
# redirect=True sends stdout/stderr to a wx popup window (default) 
app = wx.App(redirect=False)
# create window/frame, no parent, -1 is the default ID
# also increase the size of the frame for larger images
frame = wx.Frame(None, -1, size = (480, 320))
# create the panel instance
imp = ImagePanel(frame, -1)
# show the frame
frame.Show(True)
# start the GUI event loop
app.MainLoop()
sneekula commented: I like the frame work, thanks +4
bumsfeld 413 Nearly a Posting Virtuoso

Coding on the typical French beach? "Unpossible"!

bumsfeld 413 Nearly a Posting Virtuoso

If no evil would ever be done in the name of good, would there be any evil?.

bumsfeld 413 Nearly a Posting Virtuoso

I think the Pythonic approach is the use of powerful, optimized modules. So yeah, wxPython uses powerful, optimized widgets.

Python has clearly borrowed the best of several earlier languages.

bumsfeld 413 Nearly a Posting Virtuoso

Every successful enterprise requires three men - one dreamer, one businessman, and one SOB.

bumsfeld 413 Nearly a Posting Virtuoso

It is only a duck if it acts, looks and sounds like one. Processed duck is not a duck.

bumsfeld 413 Nearly a Posting Virtuoso

Unfortunately it's the World Bank that has used its heavy handed bureaucrats and their procedures to do much damage in the underdeveloped countries. The World Bank is closely associated with America (for instance past bank president Paul Wolfowoitz, architect of the Iraq war), hence the hatred.

bumsfeld 413 Nearly a Posting Virtuoso

Your class is unusual in that it is nested and does not contain any constructor. Normally constructed class is pickled this way. Dump:

# part 1 -- using module pickle with a class
# (after dumping the pickle file run part 2)

import pickle

# this class structure also has to be coded in another
# program, if you want to load the pickle file there
class authorObj():
    def __init__(self):
        pass


q = authorObj()
q.name = 'John Smith'
q.job = 'painter'

output = open('test.pkl', 'w')
pickle.dump(q, output)
output.close()

Load:

# part 2 -- using module pickle with a class
# (run part 1 first to create the pickle file)

import pickle

# needs same class structure for pickle file load
# that you used for pickle file dump
class authorObj():
    def __init__(self):
        pass


# now load again as instance q1
input = open('test.pkl', 'r')
q1 = pickle.load(input)
input.close()

print q1.name  # John Smith
print q1.job   # painter
bumsfeld 413 Nearly a Posting Virtuoso

Change

while [(t1.arm==0) or (t2.arm==0)]:

to

while (t1.arm > 0) or (t2.arm > 0):
bumsfeld 413 Nearly a Posting Virtuoso

Only the class instance is pickled, the class structure needs to be coded in the new program again:

import pickle

# this class structure also has to be coded in another
# program, if you want to load the pickle file there
class authorObj():
    class authors():
        pass


q = authorObj()
q.authors.name = 'somebody'

output = open('test.pkl', 'w')
pickle.dump(q, output)
output.close()

# now load again as instance q1

input = open('test.pkl', 'r')
q1 = pickle.load(input)
input.close()

print q1.authors.name  # somebody
bumsfeld 413 Nearly a Posting Virtuoso

Lady Helen went to her priest with her major problem. "Father, I have two female parrots, and they only know how to say one thing. All they ever say is, Hi, we're prostitutes. Want to have some fun?"

"That's terrible!" exclaimed the priest. "But I think I can help. Bring your two female parrots over to my house, and I will put them with my two male parrots whom I taught to pray and read the Bible. My parrots will teach your parrots to stop saying that terrible phrase, and your female parrots will learn to praise and worship."

The next day, Lady Helen brought her female parrots to the priest's house. His two male parrots were holding rosary beads and were quietly praying in their cage.

She put her two female parrots in the cage with the male parrots. The females said, "Hi, we're prostitutes. Want to have some fun?"

The male parrots looked at each other and burst out "Put those beads away, our prayers have been answered!"

bumsfeld 413 Nearly a Posting Virtuoso

How not to get elected:

I never give my constituents hell. I just tell the truth, and they think it is hell.
-- Harry S. Truman

bumsfeld 413 Nearly a Posting Virtuoso

Tibetans put salt in their tea instead of sugar.

bumsfeld 413 Nearly a Posting Virtuoso

Jogging is for people who aren't intelligent enough to watch television.

bumsfeld 413 Nearly a Posting Virtuoso

Write your major algorithms and test them thoroughly.

Now design the GUI and bring in the algorithms. If you are familiar with QT use PyQt, otherwise you better start with the more popular wxPython GUI toolkit. You can get drag and drop frame builder for wxPython called Boa Constructor.

Using wxPython makes distribution of your finshed program easier and has no licensing requirements like QT.

bumsfeld 413 Nearly a Posting Virtuoso

The Python interpreter is used for simple stuff, mostly one liners. You have to press the Enter key after every line you write, so the interpreter display would look something like this:

>>> def add(a, b):
...     return a + b
... 
>>> add(1, 3)
4
>>>

Ugly stuff to read and do! Use an editor to write your code , save it as for instance mycode.py and then run the file. Here is your editor code:

def add(a, b):
    return a + b

print add(1, 3)  # will display 4

Click on 'toggle plain text' to get away from the line numbers, then highlight and copy the code to your editor.

For editor use IDLE that comes with your Python installation. See:
http://www.daniweb.com/forums/post104834-1.html

bumsfeld 413 Nearly a Posting Virtuoso

I am using SPE, it's okay, it incorporates wxGlade (GUI builder) and the excellent WinPdb (debugger), but it does not have some features like code completion.

I use mostly PyScripter, it is written with Delphi, and has the features I want. It's a standalone .exe file that works on Windows.

There is free download from:
http://pyscripter.googlepages.com/

Actually, I like to use SPE for debugging and PyScripter for experimenting with Python code.

Never used Eric so far, might check it out.

bumsfeld 413 Nearly a Posting Virtuoso

Musicians serve society by providing vivid examples of excellence.

bumsfeld 413 Nearly a Posting Virtuoso

What is your operating system?
Did you use binary installer package?

For instance, in your C:\Python25\Lib\site-packages\pygame directory you should find SDL_ttf.dll for fonts and SDL_mixer.dll for sound and video. If you don't have those, your installation went bad.

bumsfeld 413 Nearly a Posting Virtuoso

Here is example how you could approach this project:

# exploring recursion

def average(qq=[]):
    """
    using empty list as default will make the list static
    recursion forms its own loop, break out with return
    """
    try:
        x = float(raw_input("Enter number (q to quit): "))
        qq.append(x)
        print "data list =", qq
        avg = sum(qq)/len(qq)
        print "average   =", avg
        # the function calls itself (recursion)
        average()
    except:
        # actually anything but number will quit
        print 'quit'
        return


average()

Not perfect, but start.

bumsfeld 413 Nearly a Posting Virtuoso

Sorry, the wxPython demo manual suggested to keep button images to 16 colours. I did that and it seemed to be working better, but there is still some flicker. I wonder, if one has to mask the image.

bumsfeld 413 Nearly a Posting Virtuoso

You need to get involved in parsing, here is example:

data = '''\
"returns=int",
"operationName=doComplexStuff",
var1="integer",
var2="(a="integer", b="integer")",
var3="(a="string", b="integer")"
'''

q = data.split(',')
m = []
t = ""
con = False
for k in range(len(q)):
    s = q[k].strip()

    # parse for () pairs and concatenate
    # before appending (set con flag)
    if '(' in s:
        con = True
    if con == True and ')' not in s:
        t += s + ','
    if ')' in s:
        t += s
        m.append(t)
        t = ""
        con = False
    elif con == False:
        m.append(s)

# show result
for w in m:
    print w

"""
my result -->
"returns=int"
"operationName=doComplexStuff"
var1="integer"
var2="(a="integer",b="integer")"
var3="(a="string",b="integer")"
"""

There are parsing modules available for Python.

bumsfeld 413 Nearly a Posting Virtuoso

Grilled pork short ribs with a bottle of home made sparkling water (cold tap water + CO2, shaken)

Are you using homemade CO2?

Cooked nice batch of ham and eggs with toast and fresh coffee.

bumsfeld 413 Nearly a Posting Virtuoso

It may be the cock that crows, but it is the hen that lays the eggs.
- Margaret Thatcher

bumsfeld 413 Nearly a Posting Virtuoso

This quote by Winston Churchill could be one good hint for George Bush:
"History will be kind to me, for I intend to write it."

bumsfeld 413 Nearly a Posting Virtuoso

A year lasts exactly 365 days, 5 hours, 48 minutes and 54.517 seconds.

bumsfeld 413 Nearly a Posting Virtuoso

Sheila Graham talking about Ronald Reagan:
"The youthful sparkle in his eyes is caused by his contact lenses, which he keeps highly polished."

bumsfeld 413 Nearly a Posting Virtuoso

Ya its amazing how useless penicillin is becoming with the resistance of pathogenic bacteria growing. They will soon run out anti-bacterial chemicals produced by fungi and humans and then were screwed.

That when phages will come back into the limelight.

Mutating bacteria and prokaryotes could eventually become the ultimate undefeated enemy.