Ene Uran 638 Posting Virtuoso

Python has a pretty fast algorithm built-in called an adaptive merge sort. Here is an example:

# sort a list of names without changing the original list
# uses the high speed sorting algorithm built-into Python

name_list1 = ['Frank', 'Mark', 'Hank', 'Zoe', 'Bob', 'Carl', 'Al']
name_list2 = sorted(name_list1)

print "Original:"
print name_list1
print "Sorted:"
print name_list2

"""my output -->
Original:
['Frank', 'Mark', 'Hank', 'Zoe', 'Bob', 'Carl', 'Al']
Sorted:
['Al', 'Bob', 'Carl', 'Frank', 'Hank', 'Mark', 'Zoe']
"""

If you have to create your own sorting algorithm, go with a selection sort. It is relatively slow, but rather easy to understand.

A selection sort of a list of numbers is pretty simple. You start
with two lists, let's call the original unsorted list the start_list
and you have another list call it the end_list which is empty at
the start.

If you want to sort ascending (lowest value first) you get the lowest
value of start_list using lowest = min(start_list) and append it to
the end_list with end_list.append(lowest). Now remove this value from
the start_list with start_list.remove(lowest) and repeat until the
start_list is empty and return the end_list with the sorted values. The repeat can be done with a while loop.

Ene Uran 638 Posting Virtuoso

Where does Red Tape come from?

jwenting commented: you should know better than to become a thread hijacking zombie master +0
Ene Uran 638 Posting Virtuoso

I like:
Spamming for Fairfax Homes
or
Spamming for windshield repair St Louis
or
Spamming for dentist new york

Have you no shame?

jephthah commented: haha +0
Ene Uran 638 Posting Virtuoso

saw it in 3d...great graphics...lame plot though...just my thought on it...

I agree, but then this is Hollywood, entertainment makes the money, a plot might happen.

Ene Uran 638 Posting Virtuoso

I think she was referring to the founders of the Tea Bag Party.

Ene Uran 638 Posting Virtuoso

Now it works, nice concept!

Ene Uran 638 Posting Virtuoso

I would say your indentations are a little screwy. Indentations are very important for Python to designate statement blocks.

Ene Uran 638 Posting Virtuoso

Duck Typing comes to mind.

Ene Uran 638 Posting Virtuoso

Very nice idea.

Ene Uran 638 Posting Virtuoso

Of course i write python scripts... i just use the shell to test fast some functions AFTER i find bugs in my script...
...
...

Then this code you gave:

myvalue = 16

command2 = r"\x03\xa2\x%02x" % myvalue

# JUST OUTPUT THE STRING INSTEAD OF PRINTING IT
command2  #\\x03\\xa2\\x10

should not give any display. See what I mean?

Ene Uran 638 Posting Virtuoso

In essence this would be the search of a 'subset' in a set:

# search for a subset in a set (Python3 syntax)

set1 = {'red','green','blue','black','orange','white'}
set2 = {'black', 'green'}

print('These are the colors common to set1 and set2:')
print(set1 & set2)

"""my result ==>
{'green', 'black'}
"""
Ene Uran 638 Posting Virtuoso

If I get a disease, I am to be blamed.

Tell that to a baby that is born with AIDS!

Ene Uran 638 Posting Virtuoso

I would tip a cow 10% and not a fraction more!

Ene Uran 638 Posting Virtuoso

Please read the note on homework help. We only help those who show at least some coding effort.

Ene Uran 638 Posting Virtuoso

The module psyco compiles to 386 machine code rather than byte code. It speeds things up a little for the Python interpreter.

To my knowledge two complete OS have been written using mostly Python, both of them are less than ideal and are used for research purposes only. Python is a high level language and has not been designed for such a low level task!

Ene Uran 638 Posting Virtuoso

I trained there and it didn't stop my drinking problem!

Ene Uran 638 Posting Virtuoso

On question four I can say that most mistakes in our organization are now made on the computer.

Ene Uran 638 Posting Virtuoso

i think toady its the same as last few months again. i dont want to grow anymore

Oh dear, do you need help?

Ene Uran 638 Posting Virtuoso

I just binged for "C Sharp lol"

Ene Uran 638 Posting Virtuoso

Wow, these guys must have searched all the junkyards of the nation. In our neighborhood you wouldn't be even allowed to throw that stuff away!

Ene Uran 638 Posting Virtuoso

The only way to serve water correctly to deserving guests!
You may want to add a drop of crude on top and serve it BP style!

Ene Uran 638 Posting Virtuoso

I still have my Barbie doll collection.

Ene Uran 638 Posting Virtuoso

Directed at printing.host

Don't you just hate signature spammers! They make the pasta you ate come right back up again! Who the heck cares about the cheap bumper stickers they peddle.

Ene Uran 638 Posting Virtuoso

Directed at ktsangop,

Are you writing your program with an editor, save it as a .py file and then run it, or are you simply running it directly from the Python interpretive shell?

If you run it from the shell, we can argue till the cows lay eggs.

Ene Uran 638 Posting Virtuoso

Usually homework like that asks for change with the least amount of coins.

Ene Uran 638 Posting Virtuoso

Just a short explanation on how to create and access a Python package:

"""
assumes that you are using Python31 installed on the c drive
1) create a directory c:/Python31/MyModules
2) write an empty file __init__.py to that directory
   ( this makes MyModules a package)
3) write a test module module1.py to that directory
   ( has one code line --> text = "text from module1" )
4) test module module1.py in c:/Python31/MyModules
   with the code below, this file can be saved anywhere

since package directory MyModules is in the Python path
it will be found, remember package names are case sensitive
as are module names
"""

import MyModules.module1 as mm_module1

print(mm_module1.text)

Just change your drive and Python version as needed. On Linux you may need root permission.

Ene Uran 638 Posting Virtuoso

Really not very complicated, just follow this sequence of actions:

"""
assumes that you are using Python31 installed on the c drive
create a directory c:/Python31/MyModules
then save this file in that directory as __init__.py
basically an code-empty file with an optional explanation
it will make MyModules a package
"""

Now directory MyModules is a package and you can put your custom modules in it, for instance this test module:

"""
now create this simple test module
and save in c:/Python31/MyModules as module1.py
"""
text = "text from module1"

Next write some code to test module1, this file can be saved anywhere and when you run Python (in this case Python 3.1.1) it will find package directory since it is in the Python search path:

"""
assumes that you are using Python31 installed on the c drive
1) create a directory c:/Python31/MyModules
2) write an empty file __init__.py to that directory
   ( this makes MyModules a package)
3) write a test module module1.py to that directory
   ( has one code line --> text = "text from module1" )
4) test module module1.py in c:/Python31/MyModules
   with the code below, this file can be saved anywhere

since package directory MyModules is in the Python search path
it will be found, remember package names are case sensitive
as are module names
"""

import MyModules.module1 as mm_module1

print(mm_module1.text)
Ene Uran 638 Posting Virtuoso

My Sony Multimedia computer is slowly giving up after 7 years of heavy use, so I am replacing it with an economically priced Dell Inspiron 545 (it's getting tough to find a regular desktop computer).

Wow, what a difference 7 years make. The price is now 1/4 of the Sony. The hard disk has jumped from 48Gb to 640Gb and internal memory is now 6Gb. It will be my first experience with Windows 7 (64bit). Wish me luck!

The old Sony will be properly recycled.

vmanes just left a note at:
http://www.daniweb.com/forums/post1127052.html#post1127052
stating that 4Gb of RAM would have cost $7500,000 in 1986.

Ene Uran 638 Posting Virtuoso

If you want to use drag and drop to design your widget layout then the PyQT GUI toolkit comes with QTdesigner, see:
http://www.daniweb.com/forums/post1108430.html#post1108430

The wxPython GUI toolkit can use BOA constructor, see:
http://www.daniweb.com/forums/post400296.html#post400296

Another nice drag and drop utility for wxPython is wxGlade.

Ene Uran 638 Posting Virtuoso

Shorten the list and add a temporary print for testing. See what that will do for you:

# shorten list for test
a = range(1, 10)
b = []
d = 0
for n in a:
    while n != 1:
        if n % 2 == 0:
            b.append(n)
            n = n/2
        elif n % 2 != 0:
            b.append(n)
            n = n*3 + 1
        else: b.append(n)
    print b, d, len(b)  # test
    if len(b) > d:
        d = len(b)
        b = []
Ene Uran 638 Posting Virtuoso

My cat took an interest in the keyboard after I left the room for a moment. It thoroughly messed up my Internet Explorer settings and took a while to fix.

Ene Uran 638 Posting Virtuoso

Sean Connery wore a toupee in every James Bond film that he starred in, beginning with Dr. No in 1962.

Ene Uran 638 Posting Virtuoso

My favorite:
"Does the doe do what does do?

Ene Uran 638 Posting Virtuoso

Today was Super Bowl Sunday (final pro football game of the season) here in the US. One of the traditional foods to watch the game with are chicken wings, honey bbq in my case. I had six friends over and we went through 5 pounds of wings and a couple of six packs of local microbrew beer. Seeing the New Orleans Saints win was a thing of beauty!

Ene Uran 638 Posting Virtuoso

Almost two more years to wait until this spectacular event will happen. Makes the rest of the wait boring.:)

Ene Uran 638 Posting Virtuoso

Liver and onions with rice and beans. Fresh California OJ.

Ene Uran 638 Posting Virtuoso

Almost invisible nano robots attacking human tissue, ouch! Lots of money to be made there!

Would make a good movie, but then who wants to see a monster movie where you can't see the monsters.

Ene Uran 638 Posting Virtuoso

That's why you should buy underwear that's yellow in front and brown in the back. :)

Anyway, yesterday I enjoyed some cherry ice cream and it had a part of a pit in it, enough to chip my tooth and now I have to spend some time at the dentist.

iamthwee commented: n1gga u iz 2 funny! +0
Ene Uran 638 Posting Virtuoso

I have only python 2.5 installed and i can find PIL in the Pythons installation directory. I use a IDE called PyScripter. When i run the program from the IDE it works fine. But it throws error when i run it from the command line.

What do you mean with run it from the command line? What is your command?

Ene Uran 638 Posting Virtuoso

Calm down, nobody has called you anything!

The thread caters to project ideas that are for the beginner. However beginners are at all sorts of levels in their learning progress. Any project takes some research, otherwise it isn't a project!

I have enjoyed the sticky's project ideas very much. Please put your clever Raffle project back into the thread. Avoid the unsubstantiated extra comments about other projects. If you manage to freeze up Python on a program you wrote, go to the regular forum and ask questions. This way you won't ask other folks to clutter up this nice thread/sticky with answers. That is what the rules imply.

It looks like the word Beginner should have been replaced by Python Enthusiast or something.

Ene Uran 638 Posting Virtuoso

Simply loop your code a million times and time the whole thing. There is also module timeit.

Ene Uran 638 Posting Virtuoso

A nano robot made to seek and destroy human sight and hearing sounds just a little too scary! Something the sickos in defense might just drool over.

Ene Uran 638 Posting Virtuoso

I saw Gallagher on TV once, what a riot! People in the front rows had to cover with plastic, as he was hitting those water melons on stage with a big hammer.

Ene Uran 638 Posting Virtuoso

The government also has the power to print money. lots of it! A measly 14 trillion, ha, just a drop in the bucket!

Ene Uran 638 Posting Virtuoso

What is important is the annual cost of the debt compared to annual GDP. That comes to about 5% of GDP. Once you have to borrow money to service the debt, then you are in deep trouble! We are not quite there yet!

The debt that our major banks have accumulated with funny money and fake loans to each other, far exceeds the national debt.

Ene Uran 638 Posting Virtuoso

This should tell DOS what kind of decoding you want to use:

# -*- coding: latin-1 -*-

print ord('é'.decode("latin-1"))     # 233
Ene Uran 638 Posting Virtuoso

This is the problem:

So what is your code?

Ene Uran 638 Posting Virtuoso

Tired of pasta? This example shows you how to show an image file picture with IronPython's .NET GUI tools:

# show an image file using IronPython downloaded from:
# http://www.codeplex.com/ironpython
# modified the example from:
# http://www.voidspace.org.uk/ironpython/winforms/part11.shtml
# image PythonHand3.jpg is attached to post
# http://www.daniweb.com/forums/post958342.html#post958342
# tested with IronPython 2.6    by ene

import clr

clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')

from System.Windows.Forms import (
    Application, DockStyle, Form, PictureBox, PictureBoxSizeMode
)
from System.Drawing import Image, Size

class MyForm(Form):
    def __init__(self):
        Form.__init__(self)
        # adjust the form's client area size to the picture
        self.ClientSize = Size(400, 300)
        # give the form a title
        self.Text = 'Explore the PictureBox()'

        # pick an image file you have in the working directory
        # or give full pathname
        fname = "PythonHand3.jpg"
        image = Image.FromFile(fname)
        pictureBox = PictureBox()
        # this will fit the image to the form
        pictureBox.SizeMode = PictureBoxSizeMode.StretchImage
        pictureBox.Image = image
        # fit the picture box to the frame
        pictureBox.Dock = DockStyle.Fill

        self.Controls.Add(pictureBox)
        self.Show()


form = MyForm()
Application.Run(form)
bumsfeld commented: very nice +11
vegaseat commented: thanks for the ironpython code +15
Ene Uran 638 Posting Virtuoso

Scrambled eggs with mushrooms, toast and OJ.

Ene Uran 638 Posting Virtuoso

Wealth created by speculation can evaporate quickly.
...

So does taxpayers money that is wasted on those speculators.