Ene Uran 638 Posting Virtuoso

If your paragraphs are properly separated, you could use something lke this:

text = """\
This is my
first paragraph.

This is my
second paragraph.

This is my
third paragraph.
"""

q = text.split('\n\n')

print q

"""
my output -->
['This is my\nfirst paragraph.',
'This is my\nsecond paragraph.',
'This is my\nthird paragraph.\n']
"""
Ene Uran 638 Posting Virtuoso

I wonder what the ecnomics of driving an all electric car are. Electricity is certainly not cheap, close to $0.1 per kwh in LA.

Then there is the capital cost of the battery, Lithium Ion would be the best for size and weight, but might add close to $30,000 to each car, and also would need to be replaced every 3 to 5 years.

Ene Uran 638 Posting Virtuoso

Well, it gives the religious right and Mr. Schwarzerneger something to do! The economy is going down the tube, but by golly at least the gays can't have a wedding!

Ene Uran 638 Posting Virtuoso

we only paid off world war 2 lend/lease borrowing to the USA in the 1990s

You should have waited for a while longer, at the rate the Dollar devalues a few Pounds could have done it!

Ene Uran 638 Posting Virtuoso

Intensive research has determined that chimpanzees were the ones that invented the "thumbs up" sign.

Ene Uran 638 Posting Virtuoso

Does God care about the outcome of sporting events?

Ene Uran 638 Posting Virtuoso

For unknown reasons, consumers have been uninterested in the 1-inch cube-shaped snack known as Wheat Thicks.

Ene Uran 638 Posting Virtuoso

In the US a movement is bubbling at the state level to ensure that future presidents are the candidates who get the most votes nationwide.

Ene Uran 638 Posting Virtuoso

We must believe in luck. For how else can we explain the success of those we don't like.

Ene Uran 638 Posting Virtuoso

Trapping a key event:

# bind keyevent to key down and display the key value

import wx

class KeyEvent(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(400, 70))
        self.SetBackgroundColour("yellow")
        # create a label
        self.label = wx.StaticText(self, wx.ID_ANY, label="  ", pos=(20, 30))

        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)

        self.Show(True)

    def OnKeyDown(self, event):
        keycode = event.GetKeyCode()
        s = "Key value = " + str(keycode)
        self.label.SetLabel(s)
        if keycode == wx.WXK_ESCAPE:
            choice = wx.MessageBox('Are you sure you want to quit? ',
                'Question', wx.YES_NO|wx.CENTRE|wx.NO_DEFAULT, self)
            if choice == wx.YES:
                self.Close()
        event.Skip()


app = wx.App()
KeyEvent(None, wx.ID_ANY, 'press any key (press escape to exit)')
app.MainLoop()
Ene Uran 638 Posting Virtuoso

The wxPython GUI toolkit has a number of ways to specify colors, or should I say colours. Here is a simple example:

# show different ways to specify colours with wxPython

import wx

class ColourTest(wx.Dialog):
    def __init__(self, parent, id, title):
        """use a dialog box as a simple window/frame"""
        wx.Dialog.__init__(self, parent, id, title, size=(300, 300))

        self.pnl1 = wx.Panel(self, -1)
        self.pnl2 = wx.Panel(self, -1)
        self.pnl3 = wx.Panel(self, -1)
        self.pnl4 = wx.Panel(self, -1)
        self.pnl5 = wx.Panel(self, -1)
        self.pnl6 = wx.Panel(self, -1)
        self.pnl7 = wx.Panel(self, -1)
        self.pnl8 = wx.Panel(self, -1)

        # use a wx.GridSizer(rows, cols, vgap, hgap) for layout
        gs = wx.GridSizer(4,2,3,3)
        # for this dialog window wx.EXPAND is not needed
        gs.AddMany([ (self.pnl1, 0 ,wx.EXPAND),
            (self.pnl2, 0, wx.EXPAND),
            (self.pnl3, 0, wx.EXPAND),
            (self.pnl4, 0, wx.EXPAND),
            (self.pnl5, 0, wx.EXPAND),
            (self.pnl6, 0, wx.EXPAND),
            (self.pnl7, 0, wx.EXPAND),
            (self.pnl8, 0, wx.EXPAND) ])

        self.SetSizer(gs)
        self.SetColors()
        self.Centre()
        self.ShowModal()
        self.Destroy()

    def SetColors(self):
        # create a number of colorful panels
        # using different ways to specify colours
        self.pnl1.SetBackgroundColour(wx.BLACK)
        # wx.Colour() uses a (r, g, b) tuple
        self.pnl2.SetBackgroundColour(wx.Colour(139,105,20))
        self.pnl3.SetBackgroundColour(wx.RED)
        # specify as #RRGGBB hex string
        self.pnl4.SetBackgroundColour('#0000FF')
        self.pnl5.SetBackgroundColour('dark green')
        self.pnl6.SetBackgroundColour('midnight blue')
        self.pnl7.SetBackgroundColour(wx.LIGHT_GREY)
        self.pnl8.SetBackgroundColour('plum')


app = wx.App()
ColourTest(None, wx.ID_ANY, 'wxPython colours')
app.MainLoop()
Ene Uran 638 Posting Virtuoso

My dad always said to me, "The early bird catches the worm".
:):):)

I rather catch the bus than a worm.

An intellectual is someone who has found something more interesting than sex.

Ene Uran 638 Posting Virtuoso

Over its 800 mile length, the TransAlaska Pipeline System on a typical day has leaks of more than 10 gallons of oil in at least 900different places.

Ene Uran 638 Posting Virtuoso

Ronald Reagan was one of the real big spenders, adding a huge junk of debt for later generations to pay. What is so great about that?

Ene Uran 638 Posting Virtuoso

You can no more win a war than you can win an earthquake.

Ene Uran 638 Posting Virtuoso

Kind of bitter sweet! Thanks Dude.

Ene Uran 638 Posting Virtuoso

What I hear, I forget. What I see, I remember. What I do, I understand.
-- Chinese Proverb

techbound commented: Nice chinese proverb! +1
Ene Uran 638 Posting Virtuoso

Well, there goes that. Video: Rice says her “time is up” :icon_razz:

Well, she might go for it if someone can explain to her that a vice president doesn't necessarily have to be the secretive troll in the basement type.

Ene Uran 638 Posting Virtuoso

Prey, good book I read about 5 years ago.

Interesting novel, has shades of the killer bees.

Ene Uran 638 Posting Virtuoso

Using raw_input() makes more sense and it is portable across the different OS and editor output windows.

Ene Uran 638 Posting Virtuoso

Nano technology can potentially lead to human engineered miniature weapons that may spread like a bacterial infection in the enemy and get out of hand.

Too bad I am not a screen writer! I live just around the corner from many of the large movie studios here in LA, and that would make one heck of a scare movie!

Ene Uran 638 Posting Virtuoso

The amount of information now available through the Internet, if formatted into books, would fill all the world's libraries nine times over.

Ene Uran 638 Posting Virtuoso

no, but both Osama and McCain are Marxists...

I thought that the slogan "There is a Marxist in every bush!" (no pun intended) went out with the nutty Senator from Wisconsin 50 years ago.

Ene Uran 638 Posting Virtuoso

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man.
- Elbert Hubbard

Ene Uran 638 Posting Virtuoso

I think actually fighting the wars for the President is much more difficult.

Ene Uran 638 Posting Virtuoso

If a deaf person swears, does her mother wash her hands with soap?

Ene Uran 638 Posting Virtuoso

Gravitation cannot be held responsible for people falling in love.
- Albert Einstein

Ene Uran 638 Posting Virtuoso

Creative writing in the buff does work well, but coding may not. I guess it depends on the program you are working on.

Ene Uran 638 Posting Virtuoso

Working in a medical facility I can tell you this:
"There are 81 year olds that are relatively bright, but the bulk of them are not!"

Did you ever watch McCain in his speeches and wonder why he smiles at the wrong times? It's unreal!

Ene Uran 638 Posting Virtuoso

Dear All,


What is the Major Differences between Python 2.3 and 2.4 and What are all the Major Features in Python 2.4??????????

regards
Mani

My understanding is that Python24 introduced a much better parser and is quite a bit faster than Python23. Python25 is the way to go if you can, it built on Python24 and introduced a number of additional functions.

Ene Uran 638 Posting Virtuoso

Not the easiest thing to do and depends heavily on your OS. Here is a DaniWeb snippet for the Windows OS:
http://www.daniweb.com/code/snippet399.html

The wxPython GUI toolkit also offers a printer widget.

Ene Uran 638 Posting Virtuoso

Is your dart game just a console game where the location the dart lands is a random pick?

Ene Uran 638 Posting Virtuoso

Are we talking GUI or CGI?

Ene Uran 638 Posting Virtuoso

There is a problem with count() as shown below:

string = "hi"

# test text
text = "hi, I am a history buff with a hideous hidrosis history"

print "Number of '" + string + "' in your file is:", text.count("hi")

"""
my result -->
Number of 'hi' in your file is: 5
"""
Ene Uran 638 Posting Virtuoso

To draw simple shapes like lines, circles, rectangles you have to use the wx.PaintDC surface as the canvas. Here are some basic examples:

# the wx.PaintDC surface is wxPython's canvas
# draw a line on this canvas
# use help(wx.PaintDC) to get more info

import wx

class DrawPanel(wx.Panel):
    """draw a line on a panel's wx.PaintDC surface/canvas"""
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)
        # bind the panel to the paint event
        wx.EVT_PAINT(self, self.onPaint)

    def onPaint(self, event=None):
        # this is the wx drawing surface/canvas
        dc = wx.PaintDC(self)
        dc.Clear()
        # sets pen color and width
        dc.SetPen(wx.Pen("blue", 1))
        x1 = 20
        y1 = 10
        x2 = 500
        y2 = 300
        # draw a line from coordinates (x1,y1) to (x2,y2)
        dc.DrawLine(x1, y1, x2, y2)


app = wx.App()
frame = wx.Frame(None, -1, "Draw a line", size=(550, 350))
dp = DrawPanel(frame)
frame.Show(True)
app.MainLoop()

You can get a little more playful, using just about the same frame work:

# the wx.PaintDC surface is wxPython's canvas
# draw a series of lines on this canvas
# DC stands for Device Context 

import wx

class DrawPanel(wx.Panel):
    """draw lines on a panel's wx.PaintDC surface/canvas"""
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)
        # bind the panel to the paint event
        wx.EVT_PAINT(self, self.onPaint)

    def onPaint(self, event=None):
        # this is the wx drawing surface/canvas
        dc = wx.PaintDC(self)
        dc.Clear()
        # sets pen color and width
        dc.SetPen(wx.Pen("red", 1))
        # set the starting point coordinates to (0,0)
        x1 = y1 = 0
        # use a loop to set the endpoint coordinates (x2,y2)
        # and draw a …
Ene Uran 638 Posting Virtuoso

Here is a templet file that allows you to package your wxPython program to an executable file with the py2exe module. It contains an XML manifest that gives the wxPython widgets a Windows XP appearance on XP machines:

# Py2Exe version 6.6 setup file for wxPython GUI programs.
# Creates a single executable file.
#
# Simply change the filename entry to whatever you called your source file.
# Optionally edit the version info and add the name of your icon file.
# It's easiest to save the modified templet code for instance as
# wx2exe.py to the same folder that containes your source file
# and the optional iconfile like "icon.ico"
#
# Now run the customized wx2exe.py ...
#
# Two subfolders will be created called build and dist.
# The dist folder contains your .exe file, MSVCR71.dll and w9xpopen.exe
# w9xpopen.exe is 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 Windows system32 folder.
# The build folder is for info only and can be deleted.


from distutils.core import setup
import py2exe
import sys

# Enter the filename of your wxPython source code file to compile.
# Your distribution file will be this filename with a .exe extension.
filename = "wxButton1.py"

# this creates the filename of your .exe file in the dist folder
if filename.endswith(".py"):
    distribution = filename[:-3]
elif filename.endswith(".pyw"):
    distribution …
sneekula commented: works well +4
Ene Uran 638 Posting Virtuoso

Fuse,
I tested all the code in your tutorial for wxPython that you so kindly contributed to the new "Starting wxPython" sticky. The code examples work like a charm on my Windows Vista machine.

Ene Uran 638 Posting Virtuoso

Be careful Vernon, fierykido is a psionist and is able to do aerokinesis. He could make the wind around you pretty foul smelling.

Nick Evan commented: Nice :) +6
Salem commented: Yeah, his arguments certainly do "blow" ;) +17
Ene Uran 638 Posting Virtuoso

Well Tammy Faye Bakker is not alive any more, maybe all those dead voters can vote for her.

However, perpetual sourpuss Ralph Nader is very much alive, and he could play the usual diversion. He likes to impeach Dick and Bush. If all the folks that hate Bush would vote for him, he would win! He has some good ideas, but I don't think he has the whole picture.

Ene Uran 638 Posting Virtuoso

Maybe we need a new sticky called "Starting wxPython" for the GUI programmers.

Ene Uran 638 Posting Virtuoso

I think you have to write it this way:
patternMatching(r"The|fox", 'The little brown fox')

Ene Uran 638 Posting Virtuoso

The Obama We Don't Know

Sounds like you won't vote for the man! So what! Lots of people like him.

Ene Uran 638 Posting Virtuoso

The wxPyton GUI toolkit has the fancier widgets for animation, graphics, plotting, sound and so on. If you are not at all familiar with GUI programming, Tkinter is a good way to start with and get the hang of it. Tkinter has a lot of sample code.

Ene Uran 638 Posting Virtuoso

got another one for ya mate.
same thing but for the date? to give me dd/mm/yy?
same as =today() in excel.
cheers.

The module time has all the methods you need to accomplish this:

import time
today = time.strftime("%d/%m/%y", time.localtime())

print today  # eg. --> 04/06/08
Ene Uran 638 Posting Virtuoso

You use a while loop like that to exit or stay in the program:

while True:
    # ...
    # you code here
    # ...
    sel = raw_input("Enter q to quit, m for more: ").lower()
    # entering q will break the loop, anything else keeps looping
    if sel == 'q':
        break
Ene Uran 638 Posting Virtuoso

Try:

text_file = open(car_model+".txt", "w")
Ene Uran 638 Posting Virtuoso

French toast with maple syrup and a big mug of Royal Kona coffee.

Ene Uran 638 Posting Virtuoso

There have only been two volcano eruptions big enough to spread ash over the entire globe in the last 2000 years.

One of them, the massive explosions of Krakatoa in Indonesia on August 26 - 27, 1883, was among the most violent volcanic events in modern times.

Ene Uran 638 Posting Virtuoso

Almost as good as driving in LA!

Actually:
http://www.telfazy.com/
has some interesting videos to watch.

Ene Uran 638 Posting Virtuoso

I went on the premise that nothing connected with MS Windows is intuitive and eventually found the answer.

The 'Microsoft® HTML Help Executable' is really hh.exe in the Windows directory. That solved the problem! Sorry about asking!